]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Handle reallocf(3) errors
authorAlejandro Colomar <alx@kernel.org>
Thu, 2 Feb 2023 11:31:54 +0000 (12:31 +0100)
committerSerge Hallyn <serge@hallyn.com>
Sat, 4 Feb 2023 04:03:38 +0000 (22:03 -0600)
Reported-by: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
src/newusers.c

index 5fd83d6ed3ed006213aebd2ad4fa9762ac9d3830..35af4e261be5d87364362d3a06a6f8f3e6de3ff9 100644 (file)
@@ -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]);