From owner-freebsd-bugs Tue Apr 10 16:40: 8 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id B5D6C37B422 for ; Tue, 10 Apr 2001 16:40:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.1/8.11.1) id f3ANe2a17877; Tue, 10 Apr 2001 16:40:02 -0700 (PDT) (envelope-from gnats) Date: Tue, 10 Apr 2001 16:40:02 -0700 (PDT) Message-Id: <200104102340.f3ANe2a17877@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Gil Kloepfer Subject: Re: misc/26486: setnetgrent hangs when netgroup contains empty netgroup Reply-To: Gil Kloepfer Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR misc/26486; it has been noted by GNATS. From: Gil Kloepfer 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 /* To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message