src/newusers.c: Exit on ENOMEM, by calling xstrdup() instead of strdup(3)

The program was happily ignoring ENOMEM errors.

Fixes: 7f9e196903 ("* NEWS, src/newusers.c, src/Makefile.am: Added support for")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2024-05-14 21:37:53 +02:00
committed by Serge Hallyn
parent 103ffc5b1d
commit ac591763fe

View 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,