aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/gen/getnetgrent.c
diff options
context:
space:
mode:
authorSteve Price <steve@FreeBSD.org>1998-03-01 18:49:37 +0000
committerSteve Price <steve@FreeBSD.org>1998-03-01 18:49:37 +0000
commitf48bc662390b27f2e1ebfc24ce66c32e7a1ac379 (patch)
tree5caf8533b63dc480aa582cb0e9307e643ecfe95b /lib/libc/gen/getnetgrent.c
parentff86df5bb22d953f0d473c62e302847e924c56fc (diff)
downloadsrc-f48bc662390b27f2e1ebfc24ce66c32e7a1ac379.tar.gz
src-f48bc662390b27f2e1ebfc24ce66c32e7a1ac379.zip
Replace previous commit with a check disallowing ptr from running
off the end of the list variable. PR: 5345, 5610 Submitted by: nagao@cs.titech.ac.jp
Notes
Notes: svn path=/head/; revision=33950
Diffstat (limited to 'lib/libc/gen/getnetgrent.c')
-rw-r--r--lib/libc/gen/getnetgrent.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c
index da6d44d384c8..cc33d1f4e6da 100644
--- a/lib/libc/gen/getnetgrent.c
+++ b/lib/libc/gen/getnetgrent.c
@@ -286,21 +286,14 @@ static int _listmatch(list, group, len)
while(isspace(*ptr))
ptr++;
- if (strchr(list, ',') == NULL) {
- if (strncmp(ptr, group, glen) == 0) {
+ while (ptr < list + len) {
+ cptr = ptr;
+ while(*ptr != ',' && *ptr != '\0' && !isspace(*ptr))
+ ptr++;
+ if (strncmp(cptr, group, glen) == 0 && glen == (ptr - cptr))
return(1);
- }
- } else {
- while (ptr < list + len) {
- cptr = ptr;
- while(*ptr != ',' && !isspace(*ptr))
- ptr++;
- if (strncmp(cptr, group, glen) == 0 &&
- glen == (ptr - cptr))
- return(1);
- while(*ptr == ',' || isspace(*ptr))
- ptr++;
- }
+ while(*ptr == ',' || isspace(*ptr))
+ ptr++;
}
return(0);