summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2023-03-02 16:18:45 +0100
committerAlejandro Colomar <alx@kernel.org>2023-05-31 21:43:33 +0200
commita710f4b9021da156c25921c2c68bec51587dea6c (patch)
tree7a06f7a0d0e7281f4670ba96246f3ec32a7d90c3
parent70399856c1e7ae6bddbe26319895fd53ab895be4 (diff)
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>
-rw-r--r--src/usermod.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/usermod.c b/src/usermod.c
index 77d4ef49..db5d37a4 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",