From 12228287c179444458ea81c2ced5bebedbd00e01 Mon Sep 17 00:00:00 2001 From: Bill Paul Date: Thu, 12 Feb 1998 19:29:05 +0000 Subject: [PATCH] Fix _listmatch() again so that it works with group lists containing only one group. Thanks to Dirk Froemberg for supplying a patch for this. I will be closing out the PR and moving this to the 2.2.5 branch later: my login sessions to freefall from Columbia are ridiculously spotty today. PR: 5610 Submitted by: Dirk Froemberg --- lib/libc/gen/getnetgrent.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c index cc04f2f0d7b..da6d44d384c 100644 --- a/lib/libc/gen/getnetgrent.c +++ b/lib/libc/gen/getnetgrent.c @@ -286,14 +286,21 @@ static int _listmatch(list, group, len) while(isspace(*ptr)) ptr++; - while (ptr < list + len) { - cptr = ptr; - while(*ptr != ',' && !isspace(*ptr)) - ptr++; - if (strncmp(cptr, group, glen) == 0 && glen == (ptr - cptr)) + if (strchr(list, ',') == NULL) { + if (strncmp(ptr, group, glen) == 0) { return(1); - while(*ptr == ',' || isspace(*ptr)) - ptr++; + } + } 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++; + } } return(0);