]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
useradd.c:fix memleak in get_groups 301/head
authorwhzhe <wanghongzhe@huawei.com>
Thu, 17 Dec 2020 08:27:15 +0000 (03:27 -0500)
committerwhzhe51 <whzhe51@126.com>
Mon, 21 Dec 2020 03:05:03 +0000 (22:05 -0500)
Signed-off-by: whzhe <wanghongzhe@huawei.com>
src/useradd.c

index 107e65f8503d9404a639c0d3822a15e075a96d45..822b67f57a9a38623235c894f5b6a0fe28f5e0ed 100644 (file)
@@ -793,6 +793,7 @@ static int get_groups (char *list)
                        fprintf (stderr,
                                 _("%s: group '%s' is a NIS group.\n"),
                                 Prog, grp->gr_name);
+                       gr_free(grp);
                        continue;
                }
 #endif
@@ -801,6 +802,7 @@ static int get_groups (char *list)
                        fprintf (stderr,
                                 _("%s: too many groups specified (max %d).\n"),
                                 Prog, ngroups);
+                       gr_free(grp);
                        break;
                }
 
@@ -808,7 +810,7 @@ static int get_groups (char *list)
                 * Add the group name to the user's list of groups.
                 */
                user_groups[ngroups++] = xstrdup (grp->gr_name);
-               free (grp);
+               gr_free (grp);
        } while (NULL != list);
 
        close_group_files ();