From 95a8de2a0aa490e9aeb1bf87ddf5833f2ae8a567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Mon, 11 Dec 2023 17:09:06 +0100 Subject: [PATCH] src/usermod,groups: use checked malloc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit usermod.c:2165: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 a62f2f56..3a8e1871 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 = MALLOC(sys_ngroups, GETGROUPS_T); + groups = XMALLOC(sys_ngroups, GETGROUPS_T); (void) setlocale (LC_ALL, ""); (void) bindtextdomain (PACKAGE, LOCALEDIR); diff --git a/src/usermod.c b/src/usermod.c index 4fe52c8a..9cbc504c 100644 --- a/src/usermod.c +++ b/src/usermod.c @@ -2161,7 +2161,7 @@ int main (int argc, char **argv) #endif sys_ngroups = sysconf (_SC_NGROUPS_MAX); - user_groups = MALLOC(sys_ngroups + 1, char *); + user_groups = XMALLOC(sys_ngroups + 1, char *); user_groups[0] = NULL; is_shadow_pwd = spw_file_present ();