]> granicus.if.org Git - shadow/commitdiff
usermod: prevent a segv
authorSerge Hallyn <shallyn@cisco.com>
Wed, 9 May 2018 02:37:55 +0000 (21:37 -0500)
committerSerge Hallyn <shallyn@cisco.com>
Wed, 9 May 2018 02:37:55 +0000 (21:37 -0500)
in the case where prefix does not exist.

Signed-off-by: Serge Hallyn <shallyn@cisco.com>
libmisc/prefix_flag.c

index 8ceffd2665b4ae10a0b7b41aa6b1dc296a4981a8..96b11faa07f748ea9eb133d1200ea4a1141e451d 100644 (file)
@@ -319,6 +319,7 @@ extern struct group *prefix_getgr_nam_gid(const char *grname)
 {
        long long int gid;
        char *endptr;
+       struct group *g;
 
        if (NULL == grname) {
                return NULL;
@@ -333,7 +334,8 @@ extern struct group *prefix_getgr_nam_gid(const char *grname)
                && (gid == (gid_t)gid)) {
                        return prefix_getgrgid ((gid_t) gid);
                }
-               return __gr_dup(prefix_getgrnam (grname));
+               g = prefix_getgrnam (grname);
+               return g ? __gr_dup(g) : NULL;
        }
        else
                return getgr_nam_gid(grname);