Date: Tue, 10 Apr 2001 16:40:02 -0700 (PDT) From: Gil Kloepfer <gil@arlut.utexas.edu> To: freebsd-bugs@FreeBSD.org Subject: Re: misc/26486: setnetgrent hangs when netgroup contains empty netgroup Message-ID: <200104102340.f3ANe2a17877@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR misc/26486; it has been noted by GNATS.
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
/*
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200104102340.f3ANe2a17877>
