]> git.cameronkatri.com Git - pw-darwin.git/commitdiff
Set the pw_class field to NULL when scanning the non-master passwd file.
authorIan Lepore <ian@FreeBSD.org>
Sun, 22 Jul 2018 22:34:20 +0000 (22:34 +0000)
committerIan Lepore <ian@FreeBSD.org>
Sun, 22 Jul 2018 22:34:20 +0000 (22:34 +0000)
This avoids a null pointer deref in pw_dup(), which assumes that all
pointers are either NULL or valid.

libc/gen/pw_scan.c

index a7dbdf2cb5b98fd6a866de50c4dca51e1aa55c5e..01146e9111d102670774dd2f3a3181599ddcb665 100644 (file)
@@ -170,7 +170,8 @@ __pw_scan(char *bp, struct passwd *pw, int flags)
                if (p[0])
                        pw->pw_fields |= _PWF_EXPIRE;
                pw->pw_expire = atol(p);
                if (p[0])
                        pw->pw_fields |= _PWF_EXPIRE;
                pw->pw_expire = atol(p);
-       }
+       } else
+               pw->pw_class = NULL;
        if (!(pw->pw_gecos = strsep(&bp, ":")))         /* gecos */
                goto fmt;
        if (pw->pw_gecos[0])
        if (!(pw->pw_gecos = strsep(&bp, ":")))         /* gecos */
                goto fmt;
        if (pw->pw_gecos[0])