Bug 32378

Summary: pwd_mkdb SIG11 on bad file + bizarness
Product: Base System Reporter: yonatan <yonatan>
Component: binAssignee: Dag-Erling Smørgrav <des>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description yonatan 2001-11-29 18:40:01 UTC
I ran pwd_mkdb on the wrong file and instead of a nice error I got
sig11 and coredump. The core can be found here:
http://j.xpert.com/pwd_mkdb/pwd_mkdb.core
The input file can be found here:
http://j.xpert.com/pwd_mkdb/asd

Other bizarness:
After the core is created pwd_mkdb leaves two empty temp files:
/etc/pwd.db.tmp
/etc/spwd.db.tmp

The next time you run pwd_mkdb it errors:
pwd_mkdb: /etc/pwd.db.tmp: File exists
but it removes this file. If you run it again you'll get:
pwd_mkdb: /etc/spwd.db.tmp: File exists
which you have to remove manually if you pwd_mkdb
to start working again.
Needless to say, all the operations described here
are run as root.

How-To-Repeat: pwd_mkdb asd
<corefile created>
pwd_mkdb asd
<see error message>
pwd_mkdb asd
<see different error message>
Comment 1 Maxim Konovalov 2001-11-29 19:38:50 UTC
Hello,

Try this patch:

Index: gen/pw_scan.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/gen/pw_scan.c,v
retrieving revision 1.17
diff -u -r1.17 pw_scan.c
--- gen/pw_scan.c	5 Mar 2001 11:58:12 -0000	1.17
+++ gen/pw_scan.c	29 Nov 2001 19:35:42 -0000
@@ -133,7 +133,8 @@
 	pw->pw_gid = id;

 	if (flags & _PWSCAN_MASTER ) {
-		pw->pw_class = strsep(&bp, ":");		/* class */
+		if (!(pw->pw_class = strsep(&bp, ":")))		/* class */
+			goto fmt;
 		if(pw->pw_class[0]) pw->pw_fields |= _PWF_CLASS;

 		if (!(p = strsep(&bp, ":")))			/* change */


You have to rebuild and reinstall libc after applying.

HTH,
	maxim

-- 
Maxim Konovalov, MAcomnet, Internet-Intranet Dept., system engineer
phone: +7 (095) 796-9079, mailto: maxim@macomnet.ru
Comment 2 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2001-12-04 12:08:07 UTC
Responsible Changed
From-To: freebsd-bugs->des

I'll take this.
Comment 3 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2001-12-04 12:33:15 UTC
State Changed
From-To: open->feedback

Fixed in -CURRENT, awaiting MFC.
Comment 4 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2001-12-11 10:52:26 UTC
State Changed
From-To: feedback->closed

Fixed in -CURRENT, and does not seem to be an issue in -STABLE.  Thanks!