This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.19-233-gdd3022d


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  dd3022d75e6fb8957843d6d84257a5d8457822d5 (commit)
       via  ea7d8b95e2fcb81f68b04ed7787a3dbda023991a (commit)
      from  df5b85da90915ce6208ad737807e3d8f2a8fce87 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=dd3022d75e6fb8957843d6d84257a5d8457822d5

commit dd3022d75e6fb8957843d6d84257a5d8457822d5
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
Date:   Thu Mar 27 19:49:51 2014 +0530

    Return NULL for wildcard values in getnetgrent from nscd (BZ #16759)
    
    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.

diff --git a/ChangeLog b/ChangeLog
index 7cf7bd1..796978d 100644
--- 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 6286681..afe4021 100644
--- 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,
diff --git a/inet/getnetgrent_r.c b/inet/getnetgrent_r.c
index 62cdfda..f6d064d 100644
--- a/inet/getnetgrent_r.c
+++ b/inet/getnetgrent_r.c
@@ -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;

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=ea7d8b95e2fcb81f68b04ed7787a3dbda023991a

commit ea7d8b95e2fcb81f68b04ed7787a3dbda023991a
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
Date:   Thu Mar 27 19:48:15 2014 +0530

    Avoid overlapping addresses to stpcpy calls in nscd (BZ #16760)
    
    Calls to stpcpy from nscd netgroups code will have overlapping source
    and destination when all three values in the returned triplet are
    non-NULL and in the expected (host,user,domain) order.  This is seen
    in valgrind as:
    
    ==3181== Source and destination overlap in stpcpy(0x19973b48, 0x19973b48)
    ==3181==    at 0x4C2F30A: stpcpy (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==3181==    by 0x12567A: addgetnetgrentX (string3.h:111)
    ==3181==    by 0x12722D: addgetnetgrent (netgroupcache.c:665)
    ==3181==    by 0x11114C: nscd_run_worker (connections.c:1338)
    ==3181==    by 0x4E3C102: start_thread (pthread_create.c:309)
    ==3181==    by 0x59B81AC: clone (clone.S:111)
    ==3181==
    
    Fix this by using memmove instead of stpcpy.

diff --git a/ChangeLog b/ChangeLog
index f6d309f..7cf7bd1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-03-27  Siddhesh Poyarekar  <siddhesh@redhat.com>
+
+	[BZ #16760]
+	* nscd/netgroupcache.c (addgetnetgrentX): Use memmove instead
+	of stpcpy.
+
 2014-03-27  Andi Kleen  <ak@linux.intel.com>
 
 	* nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h (lll_lock,
diff --git a/NEWS b/NEWS
index 895c640..6286681 100644
--- a/NEWS
+++ b/NEWS
@@ -12,7 +12,7 @@ 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.
+  16701, 16706, 16707, 16712, 16713, 16714, 16731, 16743, 16758, 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,
diff --git a/nscd/netgroupcache.c b/nscd/netgroupcache.c
index 5d15aa4..820d823 100644
--- a/nscd/netgroupcache.c
+++ b/nscd/netgroupcache.c
@@ -216,6 +216,10 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req,
 			    const char *nuser = data.val.triple.user;
 			    const char *ndomain = data.val.triple.domain;
 
+			    size_t hostlen = strlen (nhost ?: "") + 1;
+			    size_t userlen = strlen (nuser ?: "") + 1;
+			    size_t domainlen = strlen (ndomain ?: "") + 1;
+
 			    if (nhost == NULL || nuser == NULL || ndomain == NULL
 				|| nhost > nuser || nuser > ndomain)
 			      {
@@ -233,9 +237,6 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req,
 				     : last + strlen (last) + 1 - buffer);
 
 				/* We have to make temporary copies.  */
-				size_t hostlen = strlen (nhost ?: "") + 1;
-				size_t userlen = strlen (nuser ?: "") + 1;
-				size_t domainlen = strlen (ndomain ?: "") + 1;
 				size_t needed = hostlen + userlen + domainlen;
 
 				if (buflen - req->key_len - bufused < needed)
@@ -269,9 +270,12 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req,
 			      }
 
 			    char *wp = buffer + buffilled;
-			    wp = stpcpy (wp, nhost) + 1;
-			    wp = stpcpy (wp, nuser) + 1;
-			    wp = stpcpy (wp, ndomain) + 1;
+			    wp = memmove (wp, nhost ?: "", hostlen);
+			    wp += hostlen;
+			    wp = memmove (wp, nuser ?: "", userlen);
+			    wp += userlen;
+			    wp = memmove (wp, ndomain ?: "", domainlen);
+			    wp += domainlen;
 			    buffilled = wp - buffer;
 			    ++nentries;
 			  }

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog            |   10 ++++++++++
 NEWS                 |    3 ++-
 inet/getnetgrent_r.c |   14 +++++++++++---
 nscd/netgroupcache.c |   16 ++++++++++------
 4 files changed, 33 insertions(+), 10 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]