From: David Greenman Date: Fri, 27 Jan 1995 22:30:03 +0000 (+0000) Subject: Be sure to properly fail if there are not enough fields. Problem X-Git-Url: https://git.cameronkatri.com/pw-darwin.git/commitdiff_plain/e6fc7aa8756963973843f735b76491e20a4a37b8 Be sure to properly fail if there are not enough fields. Problem reported by MARC Giannoni , this fix is by me. --- diff --git a/libc/gen/pw_scan.c b/libc/gen/pw_scan.c index fbefc5b..602006e 100644 --- a/libc/gen/pw_scan.c +++ b/libc/gen/pw_scan.c @@ -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 */