diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-04-01 16:28:04 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-04-01 16:28:04 +0000 |
commit | 2caeed1ce9e9f133a401f33a2d5af607e6964523 (patch) | |
tree | 884dfd667764327121d019053b71b37e71385de1 | |
parent | 0f0320977668a926234f5cc958ed172f06a079cc (diff) |
Throw an error if the username field is empty; noticed by mpech@
-rw-r--r-- | lib/libutil/passwd.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/libutil/passwd.c b/lib/libutil/passwd.c index 75d082c6325..fce7f2a1d97 100644 --- a/lib/libutil/passwd.c +++ b/lib/libutil/passwd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: passwd.c,v 1.38 2003/03/30 21:10:27 deraadt Exp $ */ +/* $OpenBSD: passwd.c,v 1.39 2003/04/01 16:28:03 millert Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -34,7 +34,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$OpenBSD: passwd.c,v 1.38 2003/03/30 21:10:27 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: passwd.c,v 1.39 2003/04/01 16:28:03 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -515,8 +515,9 @@ pw_scan(bp, pw, flags) if (flags != (int *)NULL) *flags = 0; - if (!(pw->pw_name = strsep(&bp, ":"))) /* login */ + if (!(p = strsep(&bp, ":")) || *p == '\0') /* login */ goto fmt; + pw->pw_name = p; root = !strcmp(pw->pw_name, "root"); if (!(pw->pw_passwd = strsep(&bp, ":"))) /* passwd */ |