From: Christian Göttsche Date: Thu, 2 Mar 2023 15:18:45 +0000 (+0100) Subject: usermod: fix off-by-one issues X-Git-Tag: 4.14.0-rc1~51 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7a2b302e68a4f3e324b851c7361e40aa20a86a64;p=thirdparty%2Fshadow.git usermod: fix off-by-one issues Allocate enough memory for the strings, two slashes and the NUL terminator. Reported-by: Alejandro Colomar Signed-off-by: Alejandro Colomar --- diff --git a/src/usermod.c b/src/usermod.c index 77d4ef491..db5d37a42 100644 --- a/src/usermod.c +++ b/src/usermod.c @@ -2048,7 +2048,7 @@ static void move_mailbox (void) if (NULL == maildir) { return; } - len = strlen (prefix) + strlen (maildir) + strlen (user_name) + 2; + len = strlen (prefix) + strlen (maildir) + strlen (user_name) + 3; mailfile = ALLOCARRAY (len, char); /* @@ -2103,7 +2103,7 @@ static void move_mailbox (void) (void) close (fd); if (lflg) { - len = strlen (prefix) + strlen (maildir) + strlen (user_newname) + 2; + len = strlen (prefix) + strlen (maildir) + strlen (user_newname) + 3; newmailfile = ALLOCARRAY(len, char); if (prefix[0]) { (void) snprintf (newmailfile, len, "%s/%s/%s",