From: Christian Göttsche Date: Mon, 11 Dec 2023 16:09:06 +0000 (+0100) Subject: src/usermod,groups: use checked malloc X-Git-Tag: 4.15.0-rc1~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95a8de2a0aa490e9aeb1bf87ddf5833f2ae8a567;p=thirdparty%2Fshadow.git src/usermod,groups: use checked malloc usermod.c:2165:24: warning: dereference of possibly-NULL ‘user_groups’ [CWE-690] [-Wanalyzer-possible-null-dereference] --- diff --git a/src/groups.c b/src/groups.c index a62f2f56d..3a8e18713 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 4fe52c8ac..9cbc504c2 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 ();