summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen
diff options
context:
space:
mode:
authorsteve <steve@FreeBSD.org>1998-03-01 18:49:37 +0000
committersteve <steve@FreeBSD.org>1998-03-01 18:49:37 +0000
commitd3ce45cfa76014cd1c14da1310c58f097f3e3f2b (patch)
tree1f5b7a26e43fa6e14ad5e0bac6b4984c63277e2c /lib/libc/gen
parent8d901a5c1cd18ffc2eb644d7fece5992207b7c10 (diff)
downloadFreeBSD-src-d3ce45cfa76014cd1c14da1310c58f097f3e3f2b.zip
FreeBSD-src-d3ce45cfa76014cd1c14da1310c58f097f3e3f2b.tar.gz
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
Diffstat (limited to 'lib/libc/gen')
-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 da6d44d..cc33d1f 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);
OpenPOWER on IntegriCloud