summaryrefslogtreecommitdiff
path: root/lib/libc/gen
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2016-09-24 12:43:38 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2016-09-24 12:43:38 +0000
commit0a62ea4ef0ef215a2180679c42666bf9dc9fb7dc (patch)
tree43febed65a40fef851b48b57d0933ad0f39fd59c /lib/libc/gen
parentd00158fa6f3582a6f7a61d2ab377ee12cf467077 (diff)
Fix matching when all of user, host and domain are specified.
OK guenther@
Diffstat (limited to 'lib/libc/gen')
-rw-r--r--lib/libc/gen/getnetgrent.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c
index 82ad23f5474..bd02e09bdfe 100644
--- a/lib/libc/gen/getnetgrent.c
+++ b/lib/libc/gen/getnetgrent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getnetgrent.c,v 1.27 2015/09/14 16:09:13 tedu Exp $ */
+/* $OpenBSD: getnetgrent.c,v 1.28 2016/09/24 12:43:37 millert Exp $ */
/*
* Copyright (c) 1994 Christos Zoulas
@@ -704,20 +704,18 @@ innetgr(const char *grp, const char *host, const char *user, const char *domain)
if (in_lookup(ypdom, grp, user, domain, _NG_KEYBYUSER))
return 1;
}
- /* If a domainname is given, we would have found a match */
- if (domain != NULL)
- return 0;
-
- grpdup = strdup(grp);
- if (grpdup == NULL)
- return 0;
/* Too bad need the slow recursive way */
sl = _ng_sl_init();
- if (sl == NULL) {
- free(grpdup);
+ if (sl == NULL)
+ return 0;
+
+ grpdup = strdup(grp);
+ if (grpdup == NULL) {
+ _ng_sl_free(sl, 1);
return 0;
}
+
found = in_find(ypdom, sl, grpdup, host, user, domain);
_ng_sl_free(sl, 1);