lib/chkname.c: Take NUL byte into account
The _SC_LOGIN_NAME_MAX value includes space for the NUL byte. The
length of name must smaller than this value to be valid.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Cherry-picked-from: 403a2e3771 ("lib/chkname.c: Take NUL byte into account")
Link: <https://github.com/shadow-maint/shadow/pull/935>
Cc: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
committed by
Alejandro Colomar
parent
4b775cbff9
commit
bc0151d4d3
+1
-1
@@ -80,7 +80,7 @@ bool is_valid_user_name (const char *name)
|
||||
* User names length are limited by the kernel
|
||||
*/
|
||||
maxlen = sysconf(_SC_LOGIN_NAME_MAX);
|
||||
if (strlen(name) > maxlen)
|
||||
if (strlen(name) >= maxlen)
|
||||
return false;
|
||||
|
||||
return is_valid_name (name);
|
||||
|
||||
Reference in New Issue
Block a user