]> git.cameronkatri.com Git - pw-darwin.git/commitdiff
Be sure to properly fail if there are not enough fields. Problem
authorDavid Greenman <dg@FreeBSD.org>
Fri, 27 Jan 1995 22:30:03 +0000 (22:30 +0000)
committerDavid Greenman <dg@FreeBSD.org>
Fri, 27 Jan 1995 22:30:03 +0000 (22:30 +0000)
reported by MARC Giannoni <marc@cmc.eng.comsat.com>, this fix is by me.

libc/gen/pw_scan.c

index fbefc5b3631fe829b9051adfb61261429276b510..602006e4c4ddaa713de16af59691f6e364fe6962 100644 (file)
@@ -110,10 +110,12 @@ pw_scan(bp, pw)
        if(p[0]) pw->pw_fields |= _PWF_EXPIRE;
        pw->pw_expire = atol(p);
 
-       pw->pw_gecos = strsep(&bp, ":");                /* gecos */
+       if (!(pw->pw_gecos = strsep(&bp, ":")))         /* gecos */
+               goto fmt;
        if(pw->pw_gecos[0]) pw->pw_fields |= _PWF_GECOS;
 
-       pw->pw_dir = strsep(&bp, ":");                  /* directory */
+       if (!(pw->pw_dir = strsep(&bp, ":")))                   /* directory */
+               goto fmt;
        if(pw->pw_dir[0]) pw->pw_fields |= _PWF_DIR;
 
        if (!(pw->pw_shell = strsep(&bp, ":")))         /* shell */