diff options
author | Thomas Schwinge <thomas@codesourcery.com> | 2013-09-01 19:29:18 +0200 |
---|---|---|
committer | Thomas Schwinge <thomas@codesourcery.com> | 2013-09-01 19:29:18 +0200 |
commit | cbb58c37bb81d176f106a4de3c7f3b02dee2ff66 (patch) | |
tree | c746d229279f84aac0fe3afe537813fb281f7f78 /nscd | |
parent | ffeaf5a2df0d177a7780fd7c6f5e7595caba766a (diff) | |
parent | d5860b5273bc00632c65b43cb931d3238db0ab57 (diff) |
Merge branch 'baseline' into refs/top-bases/tschwinge/Roger_Whittaker
Conflicts:
sysdeps/mach/hurd/i386/init-first.c
sysdeps/unix/sysv/linux/ldsodefs.h
Diffstat (limited to 'nscd')
-rw-r--r-- | nscd/aicache.c | 6 | ||||
-rw-r--r-- | nscd/connections.c | 7 | ||||
-rw-r--r-- | nscd/netgroupcache.c | 32 | ||||
-rw-r--r-- | nscd/nscd_netgroup.c | 2 |
4 files changed, 30 insertions, 17 deletions
diff --git a/nscd/aicache.c b/nscd/aicache.c index 23dcf80af6..fd55852ed8 100644 --- a/nscd/aicache.c +++ b/nscd/aicache.c @@ -25,6 +25,7 @@ #include <time.h> #include <unistd.h> #include <sys/mman.h> +#include <resolv/res_hconf.h> #include "dbg_log.h" #include "nscd.h" @@ -100,8 +101,11 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req, no_more = __nss_database_lookup ("hosts", NULL, "dns [!UNAVAIL=return] files", &nip); + /* Initialize configurations. */ + if (__glibc_unlikely (!_res_hconf.initialized)) + _res_hconf_init (); if (__res_maybe_init (&_res, 0) == -1) - no_more = 1; + no_more = 1; /* If we are looking for both IPv4 and IPv6 address we don't want the lookup functions to automatically promote IPv4 addresses to diff --git a/nscd/connections.c b/nscd/connections.c index 7099215916..e54d4f213a 100644 --- a/nscd/connections.c +++ b/nscd/connections.c @@ -722,8 +722,8 @@ cannot create read-only descriptor for \"%s\"; no mmap"), cannot create read-only descriptor for \"%s\"; no mmap"), dbs[cnt].db_filename); - /* Before we create the header, initialiye the hash - table. So that if we get interrupted if writing + /* Before we create the header, initialize the hash + table. That way if we get interrupted while writing the header we can recognize a partially initialized database. */ size_t ps = sysconf (_SC_PAGESIZE); @@ -1779,7 +1779,7 @@ nscd_run_worker (void *p) else { /* Get the key. */ - char keybuf[MAXKEYLEN]; + char keybuf[MAXKEYLEN + 1]; if (__builtin_expect (TEMP_FAILURE_RETRY (read (fd, keybuf, req.key_len)) @@ -1791,6 +1791,7 @@ nscd_run_worker (void *p) strerror_r (errno, buf, sizeof (buf))); goto close_and_out; } + keybuf[req.key_len] = '\0'; if (__builtin_expect (debug_level, 0) > 0) { diff --git a/nscd/netgroupcache.c b/nscd/netgroupcache.c index 2d6c5aa459..dd06ce4fae 100644 --- a/nscd/netgroupcache.c +++ b/nscd/netgroupcache.c @@ -192,18 +192,26 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req, const char *nuser = data.val.triple.user; const char *ndomain = data.val.triple.domain; - if (data.val.triple.host > data.val.triple.user - || data.val.triple.user > data.val.triple.domain) + if (nhost == NULL || nuser == NULL || ndomain == NULL + || nhost > nuser || nuser > ndomain) { - const char *last = MAX (nhost, - MAX (nuser, ndomain)); - size_t bufused = (last + strlen (last) + 1 - - buffer); + const char *last = nhost; + if (last == NULL + || (nuser != NULL && nuser > last)) + last = nuser; + if (last == NULL + || (ndomain != NULL && ndomain > last)) + last = ndomain; + + size_t bufused + = (last == NULL + ? buffilled + : 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 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) @@ -226,11 +234,11 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req, } nhost = memcpy (buffer + bufused, - nhost, hostlen); + nhost ?: "", hostlen); nuser = memcpy ((char *) nhost + hostlen, - nuser, userlen); + nuser ?: "", userlen); ndomain = memcpy ((char *) nuser + userlen, - ndomain, domainlen); + ndomain ?: "", domainlen); } char *wp = buffer + buffilled; diff --git a/nscd/nscd_netgroup.c b/nscd/nscd_netgroup.c index cac4ebfcd3..acb2c81457 100644 --- a/nscd/nscd_netgroup.c +++ b/nscd/nscd_netgroup.c @@ -48,7 +48,7 @@ __nscd_setnetgrent (const char *group, struct __netgrent *datap) { int gc_cycle; int nretries = 0; - size_t group_len = strlen (group); + size_t group_len = strlen (group) + 1; /* If the mapping is available, try to search there instead of communicating with the nscd. */ |