Fix _listmatch() so that it doesn't fall off the end of the list string.

This commit is contained in:
Bill Paul 1995-08-08 02:51:16 +00:00
parent 228d7ef2cc
commit 22397ec3c3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=9998

View File

@ -268,15 +268,14 @@ endnetgrent()
} }
#ifdef YP #ifdef YP
static int _listmatch(list, group) static int _listmatch(list, group, len)
char *list, *group; char *list, *group;
int len;
{ {
char *ptr = list; char *ptr = list;
while (ptr != NULL) { while (ptr != (char *)(list + len)) {
if (!strncmp(ptr, group, strlen(group)) && if (!strncmp(group, ptr, strlen(group)))
(*(ptr+strlen(group)) == ',' ||
*(ptr+strlen(group)) == '\n'))
return(1); return(1);
ptr++; ptr++;
} }
@ -342,7 +341,7 @@ innetgr(group, host, user, dom)
&resultlen)) &resultlen))
free(result); free(result);
else { else {
if (_listmatch(result, group)) { if (_listmatch(result, group, resultlen)) {
free(result); free(result);
return(1); return(1);
} }