olga / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh1505647.patch

00db10
commit 1c81d55fc4b07b51adf68558ba74ce975153e580
00db10
Author: DJ Delorie <dj@redhat.com>
00db10
Date:   Thu Mar 1 23:20:45 2018 -0500
00db10
00db10
    [BZ #22342] Fix netgroup cache keys.
00db10
    
00db10
    Unlike other nscd caches, the netgroup cache contains two types of
00db10
    records - those for "iterate through a netgroup" (i.e. setnetgrent())
00db10
    and those for "is this user in this netgroup" (i.e. innetgr()),
00db10
    i.e. full and partial records.  The timeout code assumes these records
00db10
    have the same key for the group name, so that the collection of records
00db10
    that is "this netgroup" can be expired as a unit.
00db10
    
00db10
    However, the keys are not the same, as the in-netgroup key is generated
00db10
    by nscd rather than being passed to it from elsewhere, and is generated
00db10
    without the trailing NUL.  All other keys have the trailing NUL, and as
00db10
    noted in the linked BZ, debug statements confirm that two keys for the
00db10
    same netgroup are added to the cache with two different lengths.
00db10
    
00db10
    The result of this is that as records in the cache expire, the purge
00db10
    code only cleans out one of the two types of entries, resulting in
00db10
    stale, possibly incorrect, and possibly inconsistent cache data.
00db10
    
00db10
    The patch simply includes the existing NUL in the computation for the
00db10
    key length ('key' points to the char after the NUL, and 'group' to the
00db10
    first char of the group, so 'key-group' includes the first char to the
00db10
    NUL, inclusive).
00db10
    
00db10
    	[BZ #22342]
00db10
    	* nscd/netgroupcache.c (addinnetgrX): Include trailing NUL in
00db10
    	key value.
00db10
    
00db10
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
00db10
00db10
diff --git a/nscd/netgroupcache.c b/nscd/netgroupcache.c
00db10
index b832c93..2f187b2 100644
00db10
--- a/nscd/netgroupcache.c
00db10
+++ b/nscd/netgroupcache.c
00db10
@@ -480,7 +480,7 @@ addinnetgrX (struct database_dyn *db, int fd, request_header *req,
00db10
 {
00db10
   const char *group = key;
00db10
   key = (char *) rawmemchr (key, '\0') + 1;
00db10
-  size_t group_len = key - group - 1;
00db10
+  size_t group_len = key - group;
00db10
   const char *host = *key++ ? key : NULL;
00db10
   if (host != NULL)
00db10
     key = (char *) rawmemchr (key, '\0') + 1;