Skip to content

Commit

Permalink
usermod/groups: use checked malloc
Browse files Browse the repository at this point in the history
    usermod.c:2157:24: warning: dereference of possibly-NULL ‘user_groups’ [CWE-690] [-Wanalyzer-possible-null-dereference]
  • Loading branch information
cgzones committed Mar 31, 2023
1 parent e5905c4 commit acbe3d0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/groups.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/usermod.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
Expand Down

0 comments on commit acbe3d0

Please sign in to comment.