From nobody@FreeBSD.org  Thu Nov 29 10:35:16 2001
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id DD26537B417
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 29 Nov 2001 10:35:15 -0800 (PST)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.6/8.11.6) id fATIZFO53008;
	Thu, 29 Nov 2001 10:35:15 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200111291835.fATIZFO53008@freefall.freebsd.org>
Date: Thu, 29 Nov 2001 10:35:15 -0800 (PST)
From: Yonatan Bokovza <yonatan@xpert.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: pwd_mkdb SIG11 on bad file + bizarness
X-Send-Pr-Version: www-1.0

>Number:         32378
>Category:       bin
>Synopsis:       pwd_mkdb SIG11 on bad file + bizarness
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    des
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Nov 29 10:40:01 PST 2001
>Closed-Date:    Tue Dec 11 02:52:26 PST 2001
>Last-Modified:  Tue Dec 11 02:52:27 PST 2001
>Originator:     Yonatan Bokovza
>Release:        FreeBSD 4.4-Stable of 29/11/2001
>Organization:
-
>Environment:
FreeBSD Temujin.xpert.com 4.4-STABLE FreeBSD 4.4-STABLE #8: Thu Nov 29 12:18:21 IST 2001     root@Temujin.xpert.com:/usr/obj/usr/src/sys/TEMUJIN  i386

>Description:
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>
>Fix:

>Release-Note:
>Audit-Trail:

From: Maxim Konovalov <maxim@macomnet.ru>
To: Yonatan Bokovza <yonatan@xpert.com>
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: bin/32378: pwd_mkdb SIG11 on bad file + bizarness
Date: Thu, 29 Nov 2001 22:38:50 +0300 (MSK)

 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
 
Responsible-Changed-From-To: freebsd-bugs->des 
Responsible-Changed-By: des 
Responsible-Changed-When: Tue Dec 4 04:08:07 PST 2001 
Responsible-Changed-Why:  
I'll take this. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=32378 
State-Changed-From-To: open->feedback 
State-Changed-By: des 
State-Changed-When: Tue Dec 4 04:33:15 PST 2001 
State-Changed-Why:  
Fixed in -CURRENT, awaiting MFC. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=32378 
State-Changed-From-To: feedback->closed 
State-Changed-By: des 
State-Changed-When: Tue Dec 11 02:52:26 PST 2001 
State-Changed-Why:  
Fixed in -CURRENT, and does not seem to be an issue in -STABLE.  Thanks! 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=32378 
>Unformatted:
