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
This commit is contained in:
Steve Price 1998-03-01 18:49:37 +00:00
parent ff86df5bb2
commit f48bc66239
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=33950

View File

@ -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);