useradd: Fix buffer overflow when using a prefix

The buffer length did not count the string's trailing null byte.

Signed-off-by: David Michael <fedora.dm0@gmail.com>
This commit is contained in:
David Michael 2022-10-23 18:51:33 -04:00 committed by Serge Hallyn
parent 0336454503
commit eaebea55a4

View 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