From gil@arlut.utexas.edu  Tue Apr 10 09:43:06 2001
Return-Path: <gil@arlut.utexas.edu>
Received: from ns2.arlut.utexas.edu (ns2.arlut.utexas.edu [129.116.174.1])
	by hub.freebsd.org (Postfix) with ESMTP id 2E55B37B424
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 10 Apr 2001 09:43:06 -0700 (PDT)
	(envelope-from gil@arlut.utexas.edu)
Received: from ns5.arlut.utexas.edu (ns5.arlut.utexas.edu [10.4.1.6])
	by ns2.arlut.utexas.edu (8.11.3/8.11.3) with ESMTP id f3AGgtI13811
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 10 Apr 2001 11:42:55 -0500 (CDT)
Received: from csdpc2.arlut.utexas.edu (csdpc2.arlut.utexas.edu [10.3.16.31])
	by ns5.arlut.utexas.edu (8.9.3/8.9.3) with ESMTP id LAA86334
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 10 Apr 2001 11:42:55 -0500 (CDT)
Received: (from gil@localhost)
	by csdpc2.arlut.utexas.edu (8.11.1/8.9.1) id f3AGgs050799;
	Tue, 10 Apr 2001 11:42:54 -0500 (CDT)
Message-Id: <200104101642.f3AGgs050799@csdpc2.arlut.utexas.edu>
Date: Tue, 10 Apr 2001 11:42:54 -0500 (CDT)
From: gil@arlut.utexas.edu
Reply-To: gil@arlut.utexas.edu
To: FreeBSD-gnats-submit@freebsd.org
Subject: setnetgrent hangs when netgroup contains empty netgroup
X-Send-Pr-Version: 3.2

>Number:         26486
>Category:       bin
>Synopsis:       [libc] [patch] setnetgrent hangs when netgroup contains empty netgroup
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Apr 10 09:50:01 PDT 2001
>Closed-Date:    
>Last-Modified:  Thu Sep 27 07:03:38 UTC 2012
>Originator:     Gil Kloepfer
>Release:        FreeBSD 4.2-RELEASE i386
>Organization:
UT Applied Research Laboratories
>Environment:

	FreeBSD 4.2-RELEASE, and 4.3-RC2, probably others, using
	NIS netgroups.

>Description:

	NIS (yp) netgroups set-up as follows:

	ssh-users	adg-ssh-users omg-ssh-users
	adg-ssh-users
	omg-ssh-users	(-,foo,) (-,bar,)

	A call to setnetgrent("ssh-users") will hang due to the empty
	adg-ssh-users netgroup.  However, it does work when accessed
	via /etc/passwd using the +@ syntax...

>How-To-Repeat:

	using above conditions...

	#include <stdlib.h>
	#include <stdio.h>

	main()
	{
        	char            *nh, *nu, *nd;

        	printf("1\n");
        	setnetgrent("ssh-users");

        	printf("2\n");
        	nh = nu = nd = (char *)0;
        	while (getnetgrent(&nh, &nu, &nd) > 0) {
                	printf("3\n");
                	printf("> %s\n", nu);
        	}

        	printf("4\n");
        	endnetgrent();

        	printf("5\n");
        	exit(0);
	}



>Fix:

	Currently investigating where the hang is occuring.  Will update
	as soon as I find out more, unless someone else finds it first
	and lets me know.  Probably in the parse_netgrp function in
	/usr/src/lib/libc/gen/getnetgrent.c
>Release-Note:
>Audit-Trail:

From: Gil Kloepfer <gil@arlut.utexas.edu>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: misc/26486: setnetgrent hangs when netgroup contains empty netgroup
Date: Tue, 10 Apr 2001 18:31:59 -0500 (CDT)

 The problem appears to be corrected in the unified diff below.  The
 trouble seems to occur in subroutine read_for_group - if a netgroup
 with no members is read, the routine does not insert that empty
 netgroup into the linked list of netgroups.  In the YP (NIS) case,
 this will cause the routine to loop over and over trying to read
 the same netgroup looking for a non-empty one.  The code changes
 below move the check for an empty netgroup such that it only
 affects the handling of reading and parsing the remainder of
 the netgroup line.
 
 Would appreciate it VERY much if we could get this into the release
 of FreeBSD 4.3 :) :)
 
 
 --- /usr/src/lib/libc/gen/getnetgrent.c	Wed Nov  3 22:16:27 1999
 +++ getnetgrent.c	Tue Apr 10 18:25:08 2001
 @@ -570,12 +570,14 @@
  		len = pos - spos;
  		while (*pos == ' ' || *pos == '\t')
  			pos++;
 +		lp = (struct linelist *)malloc(sizeof (*lp));
 +		lp->l_parsed = 0;
 +		lp->l_groupname = (char *)malloc(len + 1);
 +		bcopy(spos, lp->l_groupname, len);
 +		*(lp->l_groupname + len) = '\0';
 +
 +		linep = (char *)0;
  		if (*pos != '\n' && *pos != '\0') {
 -			lp = (struct linelist *)malloc(sizeof (*lp));
 -			lp->l_parsed = 0;
 -			lp->l_groupname = (char *)malloc(len + 1);
 -			bcopy(spos, lp->l_groupname, len);
 -			*(lp->l_groupname + len) = '\0';
  			len = strlen(pos);
  			olen = 0;
  
 @@ -609,16 +611,17 @@
  						cont = 0;
  				}
  			} while (cont);
 -			lp->l_line = linep;
 -			lp->l_next = linehead;
 -			linehead = lp;
 -
 -			/*
 -			 * If this is the one we wanted, we are done.
 -			 */
 -			if (!strcmp(lp->l_groupname, group))
 -				return (lp);
  		}
 +
 +		lp->l_line = linep;
 +		lp->l_next = linehead;
 +		linehead = lp;
 +
 +		/*
 +		 * If this is the one we wanted, we are done.
 +		 */
 +		if (!strcmp(lp->l_groupname, group))
 +			return (lp);
  	}
  #ifdef YP
  	/*

From: Gil Kloepfer <gil@arlut.utexas.edu>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: misc/26486: setnetgrent hangs when netgroup contains empty netgroup
Date: Tue, 18 Jun 2002 21:36:03 -0500

 (blows into mic) -- Is anyone listening out there???
 
 This bug that I reported has been open for over a year now.  I've
 written to the FreeBSD core team, and have gotten little response
 (thanks Jordan for responding, and you were a great asset to the
 FreeBSD core team).
 
 Now we're at 4.6 and even though I've provided a patch for the bug,
 code to exercise the bug, and have bugged the core team about it (back
 several months ago), the bug remains open and the problem still remains.
 
 I do appreciate all the hard work that the people involved with FreeBSD
 have expended.  However, I am quite frustrated by the continued lack
 of response to this bug report and the recommended fix.  I don't
 think that this one bug should cause me to have to take the time to
 create my own sub-release of FreeBSD 4.6.
 
 Would SOMEONE please take a look at bug misc/26486 and either
 incorporate the fix into the next release (unfortunately I'm too late
 for 4.6 and I'm about to deploy this on all our FreeBSD servers)...or
 after some consideration, let me know that the fix isn't the correct
 one.  I would like to remove the hacks I've needed to put into our
 other tools in order to avoid tickling this problem.
 
 Thanks, as always, for your consideration.
 
 ---
 Gil Kloepfer - Network Support
 Applied Research Laboratories : The University of Texas at Austin
 (512) 835-3771 / gil@arlut.utexas.edu
State-Changed-From-To: open->feedback 
State-Changed-By: remko 
State-Changed-When: Wed Mar 7 21:25:32 UTC 2007 
State-Changed-Why:  
Hello, Our apologies for our late reply :( Is this still relevant 
for current FreeBSD releases? If so I will handle this for you! 


Responsible-Changed-From-To: freebsd-bugs->remko 
Responsible-Changed-By: remko 
Responsible-Changed-When: Wed Mar 7 21:25:32 UTC 2007 
Responsible-Changed-Why:  
Grab the PR and make this to a good end! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=26486 
State-Changed-From-To: feedback->closed 
State-Changed-By: linimon 
State-Changed-When: Sat Mar 1 19:43:46 UTC 2008 
State-Changed-Why:  
Feedback timeout (> 6 months). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=26486 

From: Gil Kloepfer <gil@arlut.utexas.edu>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: kern/26486: [libc] [patch] setnetgrent hangs when netgroup
	contains empty netgroup
Date: Sat, 1 Mar 2008 14:37:18 -0600

 There **WAS** feedback, but it was ignored.  See below:
 
 On Wed, Mar 07, 2007 at 03:42:22PM -0600, Gil Kloepfer wrote:
 > Remko-
 > 
 > Yes, it is still an issue but I'm not sure if the patch I submitted
 > will still work with the current 6.x source.  Let me know if you
 > need additional details.
 > 
 > -- 
 > Gil Kloepfer - ARL Network & Unix Technology Services
 > Applied Research Laboratories : The University of Texas at Austin
 > (512) 835-3771 / gil@arlut.utexas.edu
 > NOTE: Please send e-mail in plaintext ONLY.  HTML or RTF mail will NOT be read!
 > 
 > On Wed, Mar 07, 2007 at 09:26:11PM +0000, Remko Lodder wrote:
 > > Synopsis: [libc] [patch] setnetgrent hangs when netgroup contains empty netgroup
 > > 
 > > State-Changed-From-To: open->feedback
 > > State-Changed-By: remko
 > > State-Changed-When: Wed Mar 7 21:25:32 UTC 2007
 > > State-Changed-Why: 
 > > Hello, Our apologies for our late reply :( Is this still relevant
 > > for current FreeBSD releases? If so I will handle this for you!
 > > 
 > > 
 > > Responsible-Changed-From-To: freebsd-bugs->remko
 > > Responsible-Changed-By: remko
 > > Responsible-Changed-When: Wed Mar 7 21:25:32 UTC 2007
 > > Responsible-Changed-Why: 
 > > Grab the PR and make this to a good end!
 > > 
 > > http://www.freebsd.org/cgi/query-pr.cgi?pr=26486
State-Changed-From-To: closed->open 
State-Changed-By: linimon 
State-Changed-When: Sat Mar 1 23:17:26 UTC 2008 
State-Changed-Why:  
Closed by mistake. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=26486 
Responsible-Changed-From-To: remko->freebsd-bugs 
Responsible-Changed-By: remko 
Responsible-Changed-When: Thu Sep 27 07:03:17 UTC 2012 
Responsible-Changed-Why:  
Reassign to the group, I have held this locked way to long 

http://www.freebsd.org/cgi/query-pr.cgi?pr=26486 
>Unformatted:
