diff options
author | wpaul <wpaul@FreeBSD.org> | 1996-05-21 16:11:27 +0000 |
---|---|---|
committer | wpaul <wpaul@FreeBSD.org> | 1996-05-21 16:11:27 +0000 |
commit | e29507eb54815b598b32e12baaa2c46adf1d7393 (patch) | |
tree | 5c13c8cab23e6c790ebacf64533381036cfe5a5b /lib/libc/gen/getnetgrent.c | |
parent | 1c2df5ae7993ac8535051e629b38342758460d1e (diff) | |
download | FreeBSD-src-e29507eb54815b598b32e12baaa2c46adf1d7393.zip FreeBSD-src-e29507eb54815b598b32e12baaa2c46adf1d7393.tar.gz |
- Fix _listmatch() to close PR #1207.
Fix submitted by: Alan Cox <alc@cs.rice.edu>
- Nuke yet another free(result) that isn't needed. (This one I found
without phkmalloc's help. :)
Diffstat (limited to 'lib/libc/gen/getnetgrent.c')
-rw-r--r-- | lib/libc/gen/getnetgrent.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c index 67375b0..9b9d0d9 100644 --- a/lib/libc/gen/getnetgrent.c +++ b/lib/libc/gen/getnetgrent.c @@ -280,11 +280,13 @@ int len; { char *ptr = list; - if ((ptr = strstr(list, group)) == NULL) - return(0); + while (ptr = strstr(ptr, group)) { + + ptr += strlen(group); - if (*(ptr + strlen(group)) == ',' || *(ptr + strlen(group)) == '\0') - return(1); + if (*ptr == ',' || *ptr == '\0') + return(1); + } return(0); } @@ -345,11 +347,9 @@ innetgr(group, host, user, dom) if(yp_get_default_domain(&_netgr_yp_domain)) return(0); while(_buildkey(&_key, user ? user : host, dom, &rot)) { - if (yp_match(_netgr_yp_domain, user? "netgroup.byuser": + if (!yp_match(_netgr_yp_domain, user? "netgroup.byuser": "netgroup.byhost", _key, strlen(_key), &result, - &resultlen)) - free(result); - else { + &resultlen)) { rv = _listmatch(result, group, resultlen); free(result); if (rv) |