]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
src/usermod,groups: use checked malloc
authorChristian Göttsche <cgzones@googlemail.com>
Mon, 11 Dec 2023 16:09:06 +0000 (17:09 +0100)
committerSerge Hallyn <serge@hallyn.com>
Thu, 14 Dec 2023 13:40:40 +0000 (07:40 -0600)
    usermod.c:2165:24: warning: dereference of possibly-NULL ‘user_groups’ [CWE-690] [-Wanalyzer-possible-null-dereference]

src/groups.c
src/usermod.c

index a62f2f56d07285f4ab452d72e9c49473bb93b603..3a8e18713824741b965083b8fbce4ef158fc1519 100644 (file)
@@ -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);
index 4fe52c8ac4b80f3164d2d88aef22be5cd21915b5..9cbc504c2674d4c1d6616f3a6ac7b6f8a10419c9 100644 (file)
@@ -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 ();