]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
src/newusers.c: Exit on ENOMEM, by calling xstrdup() instead of strdup(3)
authorAlejandro Colomar <alx@kernel.org>
Tue, 14 May 2024 19:37:53 +0000 (21:37 +0200)
committerSerge Hallyn <serge@hallyn.com>
Tue, 2 Jul 2024 02:40:11 +0000 (21:40 -0500)
The program was happily ignoring ENOMEM errors.

Fixes: 7f9e19690333 ("* NEWS, src/newusers.c, src/Makefile.am: Added support for")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
src/newusers.c

index f2bd71c09d93f9205a3aee34577a8aaec8f1d98f..c28f8d891a3b08cfe10455d551b77483d36e1627 100644 (file)
@@ -1206,8 +1206,8 @@ int main (int argc, char **argv)
                        fail_exit (EXIT_FAILURE);
                }
                lines[nusers-1]     = line;
-               usernames[nusers-1] = strdup (fields[0]);
-               passwords[nusers-1] = strdup (fields[1]);
+               usernames[nusers-1] = xstrdup(fields[0]);
+               passwords[nusers-1] = xstrdup(fields[1]);
 #endif                         /* USE_PAM */
                if (add_passwd (&newpw, fields[1]) != 0) {
                        fprintf (stderr,