From 22397ec3c30b4edaffd606322263ab4f8a51cc20 Mon Sep 17 00:00:00 2001 From: Bill Paul Date: Tue, 8 Aug 1995 02:51:16 +0000 Subject: [PATCH] Fix _listmatch() so that it doesn't fall off the end of the list string. --- lib/libc/gen/getnetgrent.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c index b26af50f66e2..572a93a38825 100644 --- a/lib/libc/gen/getnetgrent.c +++ b/lib/libc/gen/getnetgrent.c @@ -268,15 +268,14 @@ endnetgrent() } #ifdef YP -static int _listmatch(list, group) +static int _listmatch(list, group, len) char *list, *group; +int len; { char *ptr = list; - while (ptr != NULL) { - if (!strncmp(ptr, group, strlen(group)) && - (*(ptr+strlen(group)) == ',' || - *(ptr+strlen(group)) == '\n')) + while (ptr != (char *)(list + len)) { + if (!strncmp(group, ptr, strlen(group))) return(1); ptr++; } @@ -342,7 +341,7 @@ innetgr(group, host, user, dom) &resultlen)) free(result); else { - if (_listmatch(result, group)) { + if (_listmatch(result, group, resultlen)) { free(result); return(1); }