]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Return NULL for wildcard values in getnetgrent from nscd (BZ #16759)
authorSiddhesh Poyarekar <siddhesh@redhat.com>
Thu, 27 Mar 2014 14:19:51 +0000 (19:49 +0530)
committerSiddhesh Poyarekar <siddhesh@redhat.com>
Thu, 27 Mar 2014 14:19:51 +0000 (19:49 +0530)
getnetgrent is supposed to return NULL for values that are wildcards
in the (host, user, domain) triplet.  This works correctly with nscd
disabled, but with it enabled, it returns a blank ("") instead of a
NULL.  This is easily seen with the output of `getent netgroup foonet`
for a netgroup foonet defined as follows in /etc/netgroup:

    foonet (,foo,)

The output with nscd disabled is:

    foonet ( ,foo,)

while with nscd enabled, it is:

    foonet (,foo,)

The extra space with nscd disabled is due to the fact that `getent
netgroup` adds it if the return value from getnetgrent is NULL for
either host or user.

ChangeLog
NEWS
inet/getnetgrent_r.c

index 7cf7bd1e43f868db4e2c44b42351a4cc8fdcd6ca..796978df452b237322ffdded2d484529b583d342 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2014-03-27  Siddhesh Poyarekar  <siddhesh@redhat.com>
 
+       [BZ #16759]
+       * inet/getnetgrent_r.c (get_nonempty_val): New function.
+       (nscd_getnetgrent): Use it.
+
        [BZ #16760]
        * nscd/netgroupcache.c (addgetnetgrentX): Use memmove instead
        of stpcpy.
diff --git a/NEWS b/NEWS
index 6286681b47a19b28e65121d55d53b16509b4127f..afe402133725cb46e9f85e0bebfbc276428594e1 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -12,7 +12,8 @@ Version 2.20
   15347, 15804, 15894, 16002, 16198, 16284, 16357, 16447, 16532, 16545,
   16574, 16599, 16600, 16609, 16610, 16611, 16613, 16623, 16632, 16634,
   16639, 16642, 16649, 16670, 16674, 16677, 16680, 16683, 16689, 16695,
-  16701, 16706, 16707, 16712, 16713, 16714, 16731, 16743, 16758, 16760.
+  16701, 16706, 16707, 16712, 16713, 16714, 16731, 16743, 16758, 16759,
+  16760.
 
 * Running the testsuite no longer terminates as soon as a test fails.
   Instead, a file tests.sum (xtests.sum from "make xcheck") is generated,
index 62cdfda9cbbde7ab3ea0a09dde79c8d9a624cbb9..f6d064dbb5faeb8c80ba846bcb0784bcdcec37e8 100644 (file)
@@ -235,6 +235,14 @@ endnetgrent (void)
 }
 
 #ifdef USE_NSCD
+static const char *
+get_nonempty_val (const char *in)
+{
+  if (*in == '\0')
+    return NULL;
+  return in;
+}
+
 static enum nss_status
 nscd_getnetgrent (struct __netgrent *datap, char *buffer, size_t buflen,
                  int *errnop)
@@ -243,11 +251,11 @@ nscd_getnetgrent (struct __netgrent *datap, char *buffer, size_t buflen,
     return NSS_STATUS_UNAVAIL;
 
   datap->type = triple_val;
-  datap->val.triple.host = datap->cursor;
+  datap->val.triple.host = get_nonempty_val (datap->cursor);
   datap->cursor = (char *) __rawmemchr (datap->cursor, '\0') + 1;
-  datap->val.triple.user = datap->cursor;
+  datap->val.triple.user = get_nonempty_val (datap->cursor);
   datap->cursor = (char *) __rawmemchr (datap->cursor, '\0') + 1;
-  datap->val.triple.domain = datap->cursor;
+  datap->val.triple.domain = get_nonempty_val (datap->cursor);
   datap->cursor = (char *) __rawmemchr (datap->cursor, '\0') + 1;
 
   return NSS_STATUS_SUCCESS;