* lib/defines.h: Define USER_NAME_MAX_LENGTH, based on utmp and

default to 32.
	* libmisc/chkname.c: Use USER_NAME_MAX_LENGTH.
	* src/login.c: Use USER_NAME_MAX_LENGTH instead of the default 32.
	username also needs to be bigger than USER_NAME_MAX_LENGTH because
	it has to be nul-terminated.
This commit is contained in:
nekral-guest
2009-04-22 20:42:48 +00:00
parent eae8b63d4f
commit 3704745289
4 changed files with 31 additions and 11 deletions

View File

@ -77,17 +77,11 @@ static bool is_valid_name (const char *name)
bool is_valid_user_name (const char *name)
{
#if HAVE_UTMPX_H
struct utmpx ut;
#else
struct utmp ut;
#endif
/*
* User names are limited by whatever utmp can
* handle.
*/
if (strlen (name) > sizeof (ut.ut_user)) {
if (strlen (name) > USER_NAME_MAX_LENGTH) {
return false;
}