diff options
author | David Greenman <dg@FreeBSD.org> | 1995-01-27 22:30:03 +0000 |
---|---|---|
committer | David Greenman <dg@FreeBSD.org> | 1995-01-27 22:30:03 +0000 |
commit | e6fc7aa8756963973843f735b76491e20a4a37b8 (patch) | |
tree | 0be341a3240f4de17bfdbba5777f0647c2db7c79 /libc | |
parent | 11947d5ba71b18faf8967bc5de38bc0138e5fe8a (diff) | |
download | pw-darwin-e6fc7aa8756963973843f735b76491e20a4a37b8.tar.gz pw-darwin-e6fc7aa8756963973843f735b76491e20a4a37b8.tar.zst pw-darwin-e6fc7aa8756963973843f735b76491e20a4a37b8.zip |
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.
Diffstat (limited to 'libc')
-rw-r--r-- | libc/gen/pw_scan.c | 6 |
1 files changed, 4 insertions, 2 deletions
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 */ |