]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
useradd: Fix buffer overflow when using a prefix
authorDavid Michael <fedora.dm0@gmail.com>
Sun, 23 Oct 2022 22:51:33 +0000 (18:51 -0400)
committerSerge Hallyn <serge@hallyn.com>
Mon, 24 Oct 2022 21:15:13 +0000 (16:15 -0500)
The buffer length did not count the string's trailing null byte.

Signed-off-by: David Michael <fedora.dm0@gmail.com>
src/useradd.c

index 39a744ee071c818368fe5292391f0a5aca3f9907..7ea0a9c4d87426818f71eae6099a62fff9151ef1 100644 (file)
@@ -2372,7 +2372,7 @@ static void create_mail (void)
                if (NULL == spool) {
                        return;
                }
-               file = alloca (strlen (prefix) + strlen (spool) + strlen (user_name) + 2);
+               file = alloca (strlen (prefix) + strlen (spool) + strlen (user_name) + 3);
                if (prefix[0])
                        sprintf (file, "%s/%s/%s", prefix, spool, user_name);
                else