mirror of
https://github.com/shadow-maint/shadow.git
synced 2024-12-18 14:23:52 +08:00
usermod: fix off-by-one issues
Allocate enough memory for the strings, two slashes and the NUL terminator. Reported-by: Alejandro Colomar <alx@kernel.org> Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
parent
170d24a251
commit
7a2b302e68
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user