summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Lepore <ian@FreeBSD.org>2018-07-22 22:34:20 +0000
committerIan Lepore <ian@FreeBSD.org>2018-07-22 22:34:20 +0000
commit8517a3136742981ad794e45454b834c050c3b016 (patch)
tree94be474abe336ecb547972057cd4f7a928ab89a0
parent1d9542a320d803b9bea3971687ccf33b252f2401 (diff)
downloadpw-darwin-8517a3136742981ad794e45454b834c050c3b016.tar.gz
pw-darwin-8517a3136742981ad794e45454b834c050c3b016.tar.zst
pw-darwin-8517a3136742981ad794e45454b834c050c3b016.zip
Set the pw_class field to NULL when scanning the non-master passwd file.
This avoids a null pointer deref in pw_dup(), which assumes that all pointers are either NULL or valid.
-rw-r--r--libc/gen/pw_scan.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libc/gen/pw_scan.c b/libc/gen/pw_scan.c
index a7dbdf2..01146e9 100644
--- a/libc/gen/pw_scan.c
+++ b/libc/gen/pw_scan.c
@@ -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);
- }
+ } else
+ pw->pw_class = NULL;
if (!(pw->pw_gecos = strsep(&bp, ":"))) /* gecos */
goto fmt;
if (pw->pw_gecos[0])