From acbe3d073a187da4e5bd8b8b1b9f8638adf43248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Thu, 26 Jan 2023 19:19:01 +0100 Subject: [PATCH] usermod/groups: use checked malloc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit usermod.c:2157:24: warning: dereference of possibly-NULL ‘user_groups’ [CWE-690] [-Wanalyzer-possible-null-dereference] --- src/groups.c | 2 +- src/usermod.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/groups.c b/src/groups.c index 1d1c646e85..b9bb939812 100644 --- a/src/groups.c +++ b/src/groups.c @@ -91,7 +91,7 @@ int main (int argc, char **argv) GETGROUPS_T *groups; sys_ngroups = sysconf (_SC_NGROUPS_MAX); - groups = MALLOCARRAY (sys_ngroups, GETGROUPS_T); + groups = XMALLOCARRAY (sys_ngroups, GETGROUPS_T); (void) setlocale (LC_ALL, ""); (void) bindtextdomain (PACKAGE, LOCALEDIR); diff --git a/src/usermod.c b/src/usermod.c index 05cc28fbad..7d90460017 100644 --- a/src/usermod.c +++ b/src/usermod.c @@ -2152,7 +2152,7 @@ int main (int argc, char **argv) #endif sys_ngroups = sysconf (_SC_NGROUPS_MAX); - user_groups = MALLOCARRAY (sys_ngroups + 1, char *); + user_groups = XMALLOCARRAY (sys_ngroups + 1, char *); user_groups[0] = NULL; is_shadow_pwd = spw_file_present ();