Be sure to properly fail if there are not enough fields. Problem

reported by MARC Giannoni <marc@cmc.eng.comsat.com>, this fix is by me.
This commit is contained in:
David Greenman 1995-01-27 22:30:03 +00:00
parent 5d20b0e1a2
commit cc6f628176
2 changed files with 8 additions and 4 deletions

View 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 */

View 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 */