Currently, innetgr(3) will return false if all of user, host and
domain are specified, even if the tuple would otherwise match.

The commented assumption "If a domainname is given, we would have
found a match" is simply not true.

I also moved the strdup after the "Too bad need the slow recursive
way" comment for readability.

 - todd

Index: lib/libc/gen/getnetgrent.c
===================================================================
RCS file: /cvs/src/lib/libc/gen/getnetgrent.c,v
retrieving revision 1.27
diff -u -p -u -r1.27 getnetgrent.c
--- lib/libc/gen/getnetgrent.c  14 Sep 2015 16:09:13 -0000      1.27
+++ lib/libc/gen/getnetgrent.c  13 Sep 2016 19:54:38 -0000
@@ -704,20 +704,16 @@ innetgr(const char *grp, const char *hos
                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)
+
+       /* Too bad need the slow recursive way */
+       sl = _ng_sl_init();
+       if (sl == 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);
-               return 0;
-       }
        found = in_find(ypdom, sl, grpdup, host, user, domain);
        _ng_sl_free(sl, 1);
 

Reply via email to