|
|
29e444 |
commit 50fd745b4dec07e8e213cf2703b5cabcfa128225
|
|
|
29e444 |
Author: Andreas Schwab <schwab@suse.de>
|
|
|
29e444 |
Date: Mon Jun 10 14:39:09 2013 +0200
|
|
|
29e444 |
|
|
|
29e444 |
Fix handling of netgroup cache in nscd
|
|
|
29e444 |
|
|
|
12745e |
diff --git glibc-2.17-c758a686/nscd/connections.c glibc-2.17-c758a686/nscd/connections.c
|
|
|
29e444 |
index 7099215..69e3e7d 100644
|
|
|
12745e |
--- glibc-2.17-c758a686/nscd/connections.c
|
|
|
12745e |
+++ glibc-2.17-c758a686/nscd/connections.c
|
|
|
29e444 |
@@ -1779,7 +1779,7 @@ nscd_run_worker (void *p)
|
|
|
29e444 |
else
|
|
|
29e444 |
{
|
|
|
29e444 |
/* Get the key. */
|
|
|
29e444 |
- char keybuf[MAXKEYLEN];
|
|
|
29e444 |
+ char keybuf[MAXKEYLEN + 1];
|
|
|
29e444 |
|
|
|
29e444 |
if (__builtin_expect (TEMP_FAILURE_RETRY (read (fd, keybuf,
|
|
|
29e444 |
req.key_len))
|
|
|
29e444 |
@@ -1791,6 +1791,7 @@ nscd_run_worker (void *p)
|
|
|
29e444 |
strerror_r (errno, buf, sizeof (buf)));
|
|
|
29e444 |
goto close_and_out;
|
|
|
29e444 |
}
|
|
|
29e444 |
+ keybuf[req.key_len] = '\0';
|
|
|
29e444 |
|
|
|
29e444 |
if (__builtin_expect (debug_level, 0) > 0)
|
|
|
29e444 |
{
|
|
|
12745e |
diff --git glibc-2.17-c758a686/nscd/netgroupcache.c glibc-2.17-c758a686/nscd/netgroupcache.c
|
|
|
29e444 |
index 2d6c5aa..dd06ce4 100644
|
|
|
12745e |
--- glibc-2.17-c758a686/nscd/netgroupcache.c
|
|
|
12745e |
+++ glibc-2.17-c758a686/nscd/netgroupcache.c
|
|
|
29e444 |
@@ -192,18 +192,26 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req,
|
|
|
29e444 |
const char *nuser = data.val.triple.user;
|
|
|
29e444 |
const char *ndomain = data.val.triple.domain;
|
|
|
29e444 |
|
|
|
29e444 |
- if (data.val.triple.host > data.val.triple.user
|
|
|
29e444 |
- || data.val.triple.user > data.val.triple.domain)
|
|
|
29e444 |
+ if (nhost == NULL || nuser == NULL || ndomain == NULL
|
|
|
29e444 |
+ || nhost > nuser || nuser > ndomain)
|
|
|
29e444 |
{
|
|
|
29e444 |
- const char *last = MAX (nhost,
|
|
|
29e444 |
- MAX (nuser, ndomain));
|
|
|
29e444 |
- size_t bufused = (last + strlen (last) + 1
|
|
|
29e444 |
- - buffer);
|
|
|
29e444 |
+ const char *last = nhost;
|
|
|
29e444 |
+ if (last == NULL
|
|
|
29e444 |
+ || (nuser != NULL && nuser > last))
|
|
|
29e444 |
+ last = nuser;
|
|
|
29e444 |
+ if (last == NULL
|
|
|
29e444 |
+ || (ndomain != NULL && ndomain > last))
|
|
|
29e444 |
+ last = ndomain;
|
|
|
29e444 |
+
|
|
|
29e444 |
+ size_t bufused
|
|
|
29e444 |
+ = (last == NULL
|
|
|
29e444 |
+ ? buffilled
|
|
|
29e444 |
+ : last + strlen (last) + 1 - buffer);
|
|
|
29e444 |
|
|
|
29e444 |
/* We have to make temporary copies. */
|
|
|
29e444 |
- size_t hostlen = strlen (nhost) + 1;
|
|
|
29e444 |
- size_t userlen = strlen (nuser) + 1;
|
|
|
29e444 |
- size_t domainlen = strlen (ndomain) + 1;
|
|
|
29e444 |
+ size_t hostlen = strlen (nhost ?: "") + 1;
|
|
|
29e444 |
+ size_t userlen = strlen (nuser ?: "") + 1;
|
|
|
29e444 |
+ size_t domainlen = strlen (ndomain ?: "") + 1;
|
|
|
29e444 |
size_t needed = hostlen + userlen + domainlen;
|
|
|
29e444 |
|
|
|
29e444 |
if (buflen - req->key_len - bufused < needed)
|
|
|
29e444 |
@@ -226,11 +234,11 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req,
|
|
|
29e444 |
}
|
|
|
29e444 |
|
|
|
29e444 |
nhost = memcpy (buffer + bufused,
|
|
|
29e444 |
- nhost, hostlen);
|
|
|
29e444 |
+ nhost ?: "", hostlen);
|
|
|
29e444 |
nuser = memcpy ((char *) nhost + hostlen,
|
|
|
29e444 |
- nuser, userlen);
|
|
|
29e444 |
+ nuser ?: "", userlen);
|
|
|
29e444 |
ndomain = memcpy ((char *) nuser + userlen,
|
|
|
29e444 |
- ndomain, domainlen);
|
|
|
29e444 |
+ ndomain ?: "", domainlen);
|
|
|
29e444 |
}
|
|
|
29e444 |
|
|
|
29e444 |
char *wp = buffer + buffilled;
|
|
|
12745e |
diff --git glibc-2.17-c758a686/nscd/nscd_netgroup.c glibc-2.17-c758a686/nscd/nscd_netgroup.c
|
|
|
29e444 |
index cac4ebf..acb2c81 100644
|
|
|
12745e |
--- glibc-2.17-c758a686/nscd/nscd_netgroup.c
|
|
|
12745e |
+++ glibc-2.17-c758a686/nscd/nscd_netgroup.c
|
|
|
29e444 |
@@ -48,7 +48,7 @@ __nscd_setnetgrent (const char *group, struct __netgrent *datap)
|
|
|
29e444 |
{
|
|
|
29e444 |
int gc_cycle;
|
|
|
29e444 |
int nretries = 0;
|
|
|
29e444 |
- size_t group_len = strlen (group);
|
|
|
29e444 |
+ size_t group_len = strlen (group) + 1;
|
|
|
29e444 |
|
|
|
29e444 |
/* If the mapping is available, try to search there instead of
|
|
|
29e444 |
communicating with the nscd. */
|