]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/chkname.c: Take NUL byte into account
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sat, 3 Feb 2024 00:07:58 +0000 (01:07 +0100)
committerAlejandro Colomar <alx@kernel.org>
Sun, 4 Feb 2024 23:46:30 +0000 (00:46 +0100)
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: 403a2e3771be ("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>
lib/chkname.c

index d22e1b6b455c2f8b8d971d3abce3ead34242f8c1..d14e44a599bacc17a413dd351019fcf90042b38a 100644 (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);