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>
This commit is contained in:
Tobias Stoeckmann
2024-02-03 01:07:58 +01:00
committed by Serge Hallyn
parent 37b02a5f88
commit 403a2e3771
2 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -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);