Close PR #4867: improve _listmatch() to avoid returning false positives.

PR: 4867
This commit is contained in:
wpaul 1997-11-16 03:02:39 +00:00
parent 0bdadfcd1b
commit 5a4ed48dff

View File

@ -276,17 +276,24 @@ endnetgrent()
#ifdef YP #ifdef YP
static int _listmatch(list, group, len) static int _listmatch(list, group, len)
char *list, *group; char *list, *group;
int len; int len;
{ {
char *ptr = list; char *ptr = list, *cptr;
int glen = strlen(group);
while ( (ptr = strstr(ptr, group)) ) { /* skip possible leading whitespace */
while(isspace(*ptr))
ptr++;
ptr += strlen(group); while (ptr < list + len) {
cptr = ptr;
if (*ptr == ',' || *ptr == '\0') while(*ptr != ',' && !isspace(*ptr))
ptr++;
if (strncmp(cptr, group, glen) == 0 && glen == (ptr - cptr))
return(1); return(1);
while(*ptr == ',' || isspace(*ptr))
ptr++;
} }
return(0); return(0);