From clkao@genius.cirx.org  Wed Nov 18 16:51:22 1998
Received: from genius.cirx.org (r00t.m1.ntu.edu.tw [140.112.240.59])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id QAA12957
          for <FreeBSD-gnats-submit@freebsd.org>; Wed, 18 Nov 1998 16:47:57 -0800 (PST)
          (envelope-from clkao@genius.cirx.org)
Received: (from root@localhost)
	by genius.cirx.org (8.9.1/8.8.8) id CAA27802;
	Thu, 19 Nov 1998 02:24:08 +0800 (CST)
	(envelope-from clkao)
Message-Id: <199811181824.CAA27802@genius.cirx.org>
Date: Thu, 19 Nov 1998 02:24:08 +0800 (CST)
From: clkao@CirX.ORG
Reply-To: clkao@CirX.ORG
To: FreeBSD-gnats-submit@freebsd.org
Subject: pwd_mkdb problem when having comments in passwd file
X-Send-Pr-Version: 3.2

>Number:         8753
>Category:       bin
>Synopsis:       pwd_mkdb problem when having comments in passwd file
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Nov 18 17:00:00 PST 1998
>Closed-Date:    Sat Dec 12 08:09:38 PST 1998
>Last-Modified:  Sat Dec 12 08:23:42 PST 1998
>Originator:     Chia-liang Kao
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
CirX
>Environment:

FreeBSD genius.cirx.org 3.0-CURRENT FreeBSD 3.0-CURRENT #9: Fri Oct 23 01:36:18 CST 1998     clkao@genius.cirx.org:/usr/src/sys/compile/GENIUS  i386

>Description:

getpwent in libc access the db file with a incresing key number; 
where the key pwd_mkdb used is still increasing even if the line is a comment.

Thus, getpwent will fail to retreive the data with the missing key, returning
NULL and the applications will think it is the end of the world.

>How-To-Repeat:

and an empty line or a comment in your master.passwd file and re-pwd_mkdb it.

>Fix:
	
	apply the following patch:
Index: pwd_mkdb.c
===================================================================
RCS file: /usr/local/ncvs//src/usr.sbin/pwd_mkdb/pwd_mkdb.c,v
retrieving revision 1.27
diff -u -r1.27 pwd_mkdb.c
--- pwd_mkdb.c	1998/09/29 20:01:21	1.27
+++ pwd_mkdb.c	1998/11/18 18:16:25
@@ -287,6 +287,10 @@
 		    (pwd.pw_name[0] == '+' || pwd.pw_name[0] == '-'))
 			yp_enabled = 1;
 #define	COMPACT(e)	t = e; while ((*p++ = *t++));
+#ifdef PASSWD_IGNORE_COMMENTS
+		if(is_comment)
+			--cnt;
+#endif
 		if (!is_comment && 
 		    (!username || (strcmp(username, pwd.pw_name) == 0))) {
 			/* Create insecure data. */
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: foxfair 
State-Changed-When: Sat Dec 12 08:09:38 PST 1998 
State-Changed-Why:  
Patch committed. Thanks! 
>Unformatted:
