From: Alejandro Colomar Date: Thu, 2 Feb 2023 11:31:54 +0000 (+0100) Subject: Handle reallocf(3) errors X-Git-Tag: 4.14.0-rc1~194 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f301a4ca19533a5c93bba44db2d8e345fa909e35;p=thirdparty%2Fshadow.git Handle reallocf(3) errors Reported-by: Iker Pedrosa Signed-off-by: Alejandro Colomar --- diff --git a/src/newusers.c b/src/newusers.c index 5fd83d6ed..35af4e261 100644 --- a/src/newusers.c +++ b/src/newusers.c @@ -1203,6 +1203,13 @@ int main (int argc, char **argv) lines = reallocf (lines, sizeof (lines[0]) * nusers); usernames = reallocf (usernames, sizeof (usernames[0]) * nusers); passwords = reallocf (passwords, sizeof (passwords[0]) * nusers); + if (lines == NULL || usernames == NULL || passwords == NULL) { + fprintf (stderr, + _("%s: line %d: %s\n"), + Prog, line, strerror(errno)); + errors++; + continue; + } lines[nusers-1] = line; usernames[nusers-1] = strdup (fields[0]); passwords[nusers-1] = strdup (fields[1]);