From ac591763febcc05bfefb046cee38f12bb4c1e76f Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Tue, 14 May 2024 21:37:53 +0200 Subject: [PATCH] src/newusers.c: Exit on ENOMEM, by calling xstrdup() instead of strdup(3) The program was happily ignoring ENOMEM errors. Fixes: 7f9e19690333 ("* NEWS, src/newusers.c, src/Makefile.am: Added support for") Signed-off-by: Alejandro Colomar --- src/newusers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/newusers.c b/src/newusers.c index f2bd71c09..c28f8d891 100644 --- a/src/newusers.c +++ b/src/newusers.c @@ -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, -- 2.47.3