Auto-sync with upstream branch master

Upstream commit: d8425e116cdd954fea0c04c0f406179b5daebbb3
This commit is contained in:
Florian Weimer 2017-10-11 07:19:54 +02:00
parent d3da0e913a
commit b1ee1018fc
3 changed files with 147 additions and 244 deletions

View File

@ -239,8 +239,9 @@ Date: Sun Mar 1 23:22:45 2015 +0100
[BZ #18023] [BZ #18023]
* include/alloca.h (stackinfo_alloca_round, extend_alloca, * include/alloca.h (stackinfo_alloca_round, extend_alloca,
extend_alloca_account): Remove. extend_alloca_account): Remove.
Index: b/elf/dl-deps.c
=================================================================== diff --git a/elf/dl-deps.c b/elf/dl-deps.c
index 35cad364b7dfdf0d..0fae87a0bb976335 100644
--- a/elf/dl-deps.c --- a/elf/dl-deps.c
+++ b/elf/dl-deps.c +++ b/elf/dl-deps.c
@@ -27,6 +27,7 @@ @@ -27,6 +27,7 @@
@ -251,7 +252,7 @@ Index: b/elf/dl-deps.c
#include <dl-dst.h> #include <dl-dst.h>
@@ -184,9 +185,8 @@ _dl_map_object_deps (struct link_map *ma @@ -181,9 +182,8 @@ _dl_map_object_deps (struct link_map *map,
/* Pointer to last unique object. */ /* Pointer to last unique object. */
tail = &known[nlist - 1]; tail = &known[nlist - 1];
@ -263,7 +264,7 @@ Index: b/elf/dl-deps.c
/* Process each element of the search list, loading each of its /* Process each element of the search list, loading each of its
auxiliary objects and immediate dependencies. Auxiliary objects auxiliary objects and immediate dependencies. Auxiliary objects
@@ -217,13 +217,12 @@ _dl_map_object_deps (struct link_map *ma @@ -213,13 +213,12 @@ _dl_map_object_deps (struct link_map *map,
if (l->l_searchlist.r_list == NULL && l->l_initfini == NULL if (l->l_searchlist.r_list == NULL && l->l_initfini == NULL
&& l != map && l->l_ldnum > 0) && l != map && l->l_ldnum > 0)
{ {
@ -283,7 +284,7 @@ Index: b/elf/dl-deps.c
} }
if (l->l_info[DT_NEEDED] || l->l_info[AUXTAG] || l->l_info[FILTERTAG]) if (l->l_info[DT_NEEDED] || l->l_info[AUXTAG] || l->l_info[FILTERTAG])
@@ -463,8 +462,11 @@ _dl_map_object_deps (struct link_map *ma @@ -438,8 +437,11 @@ _dl_map_object_deps (struct link_map *map,
struct link_map **l_initfini = (struct link_map **) struct link_map **l_initfini = (struct link_map **)
malloc ((2 * nneeded + 1) * sizeof needed[0]); malloc ((2 * nneeded + 1) * sizeof needed[0]);
if (l_initfini == NULL) if (l_initfini == NULL)
@ -297,7 +298,7 @@ Index: b/elf/dl-deps.c
l_initfini[0] = l; l_initfini[0] = l;
memcpy (&l_initfini[1], needed, nneeded * sizeof needed[0]); memcpy (&l_initfini[1], needed, nneeded * sizeof needed[0]);
memcpy (&l_initfini[nneeded + 1], l_initfini, memcpy (&l_initfini[nneeded + 1], l_initfini,
@@ -482,6 +484,8 @@ _dl_map_object_deps (struct link_map *ma @@ -457,6 +459,8 @@ _dl_map_object_deps (struct link_map *map,
} }
out: out:
@ -306,8 +307,8 @@ Index: b/elf/dl-deps.c
if (errno == 0 && errno_saved != 0) if (errno == 0 && errno_saved != 0)
__set_errno (errno_saved); __set_errno (errno_saved);
Index: b/include/alloca.h diff --git a/include/alloca.h b/include/alloca.h
=================================================================== index fd90664f0a17cd6d..c0b83954436ed4c1 100644
--- a/include/alloca.h --- a/include/alloca.h
+++ b/include/alloca.h +++ b/include/alloca.h
@@ -23,57 +23,17 @@ libc_hidden_proto (__libc_alloca_cutoff) @@ -23,57 +23,17 @@ libc_hidden_proto (__libc_alloca_cutoff)
@ -368,79 +369,8 @@ Index: b/include/alloca.h
#endif #endif
# endif /* !_ISOMAC */ # endif /* !_ISOMAC */
Index: b/nss/nss_compat/compat-initgroups.c diff --git a/nis/nss_nis/nis-initgroups.c b/nis/nss_nis/nis-initgroups.c
=================================================================== index 3784c101f7ee31aa..c872b32e15f55e3d 100644
--- a/nss/nss_compat/compat-initgroups.c
+++ b/nss/nss_compat/compat-initgroups.c
@@ -262,7 +262,6 @@ getgrent_next_nss (ent_t *ent, char *buf
overwrite the pointer with one to a bigger buffer. */
char *tmpbuf = buffer;
size_t tmplen = buflen;
- bool use_malloc = false;
for (int i = 0; i < mystart; i++)
{
@@ -271,29 +270,26 @@ getgrent_next_nss (ent_t *ent, char *buf
== NSS_STATUS_TRYAGAIN
&& *errnop == ERANGE)
{
- if (__libc_use_alloca (tmplen * 2))
- {
- if (tmpbuf == buffer)
- {
- tmplen *= 2;
- tmpbuf = __alloca (tmplen);
- }
- else
- tmpbuf = extend_alloca (tmpbuf, tmplen, tmplen * 2);
- }
- else
- {
- tmplen *= 2;
- char *newbuf = realloc (use_malloc ? tmpbuf : NULL, tmplen);
-
- if (newbuf == NULL)
- {
- status = NSS_STATUS_TRYAGAIN;
- goto done;
- }
- use_malloc = true;
- tmpbuf = newbuf;
- }
+ /* Check for overflow. */
+ if (__glibc_unlikely (tmplen * 2 < tmplen))
+ {
+ __set_errno (ENOMEM);
+ status = NSS_STATUS_TRYAGAIN;
+ goto done;
+ }
+ /* Increase the size. Make sure that we retry
+ with a reasonable size. */
+ tmplen *= 2;
+ if (tmplen < 1024)
+ tmplen = 1024;
+ if (tmpbuf != buffer)
+ free (tmpbuf);
+ tmpbuf = malloc (tmplen);
+ if (__glibc_unlikely (tmpbuf == NULL))
+ {
+ status = NSS_STATUS_TRYAGAIN;
+ goto done;
+ }
}
if (__builtin_expect (status != NSS_STATUS_NOTFOUND, 1))
@@ -321,7 +317,7 @@ getgrent_next_nss (ent_t *ent, char *buf
status = NSS_STATUS_NOTFOUND;
done:
- if (use_malloc)
+ if (tmpbuf != buffer)
free (tmpbuf);
}
Index: b/nis/nss_nis/nis-initgroups.c
===================================================================
--- a/nis/nss_nis/nis-initgroups.c --- a/nis/nss_nis/nis-initgroups.c
+++ b/nis/nss_nis/nis-initgroups.c +++ b/nis/nss_nis/nis-initgroups.c
@@ -16,7 +16,6 @@ @@ -16,7 +16,6 @@
@ -459,7 +389,7 @@ Index: b/nis/nss_nis/nis-initgroups.c
#include "nss-nis.h" #include "nss-nis.h"
#include <libnsl.h> #include <libnsl.h>
@@ -120,27 +120,30 @@ internal_getgrent_r (struct group *grp, @@ -120,27 +120,30 @@ internal_getgrent_r (struct group *grp, char *buffer, size_t buflen,
static int static int
get_uid (const char *user, uid_t *uidp) get_uid (const char *user, uid_t *uidp)
{ {
@ -494,7 +424,7 @@ Index: b/nis/nss_nis/nis-initgroups.c
return 1; return 1;
} }
@@ -254,8 +257,6 @@ _nss_nis_initgroups_dyn (const char *use @@ -254,8 +257,6 @@ _nss_nis_initgroups_dyn (const char *user, gid_t group, long int *start,
} }
struct group grpbuf, *g; struct group grpbuf, *g;
@ -503,7 +433,7 @@ Index: b/nis/nss_nis/nis-initgroups.c
enum nss_status status; enum nss_status status;
intern_t intern = { NULL, NULL, 0 }; intern_t intern = { NULL, NULL, 0 };
gid_t *groups = *groupsp; gid_t *groups = *groupsp;
@@ -264,15 +265,21 @@ _nss_nis_initgroups_dyn (const char *use @@ -264,15 +265,21 @@ _nss_nis_initgroups_dyn (const char *user, gid_t group, long int *start,
if (status != NSS_STATUS_SUCCESS) if (status != NSS_STATUS_SUCCESS)
return status; return status;
@ -536,8 +466,8 @@ Index: b/nis/nss_nis/nis-initgroups.c
return status; return status;
} }
Index: b/nscd/aicache.c diff --git a/nscd/aicache.c b/nscd/aicache.c
=================================================================== index a3de792cc429b546..7064d12a15b3e19d 100644
--- a/nscd/aicache.c --- a/nscd/aicache.c
+++ b/nscd/aicache.c +++ b/nscd/aicache.c
@@ -28,6 +28,7 @@ @@ -28,6 +28,7 @@
@ -548,7 +478,7 @@ Index: b/nscd/aicache.c
#include "dbg_log.h" #include "dbg_log.h"
#include "nscd.h" #include "nscd.h"
@@ -111,10 +112,13 @@ addhstaiX (struct database_dyn *db, int @@ -111,10 +112,13 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
if (ctx == NULL) if (ctx == NULL)
no_more = 1; no_more = 1;
@ -566,7 +496,7 @@ Index: b/nscd/aicache.c
int32_t ttl = INT32_MAX; int32_t ttl = INT32_MAX;
ssize_t total = 0; ssize_t total = 0;
char *key_copy = NULL; char *key_copy = NULL;
@@ -127,6 +131,7 @@ addhstaiX (struct database_dyn *db, int @@ -127,6 +131,7 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
int status[2] = { NSS_STATUS_UNAVAIL, NSS_STATUS_UNAVAIL }; int status[2] = { NSS_STATUS_UNAVAIL, NSS_STATUS_UNAVAIL };
int naddrs = 0; int naddrs = 0;
size_t addrslen = 0; size_t addrslen = 0;
@ -574,7 +504,7 @@ Index: b/nscd/aicache.c
char *canon = NULL; char *canon = NULL;
size_t canonlen; size_t canonlen;
@@ -141,12 +146,17 @@ addhstaiX (struct database_dyn *db, int @@ -141,12 +146,17 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
at = &atmem; at = &atmem;
rc6 = 0; rc6 = 0;
herrno = 0; herrno = 0;
@ -594,7 +524,7 @@ Index: b/nscd/aicache.c
} }
if (rc6 != 0 && herrno == NETDB_INTERNAL) if (rc6 != 0 && herrno == NETDB_INTERNAL)
@@ -224,41 +234,38 @@ addhstaiX (struct database_dyn *db, int @@ -224,41 +234,38 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
while (1) while (1)
{ {
rc6 = 0; rc6 = 0;
@ -652,7 +582,7 @@ Index: b/nscd/aicache.c
} }
if (rc4 != 0 && herrno == NETDB_INTERNAL) if (rc4 != 0 && herrno == NETDB_INTERNAL)
@@ -284,13 +291,11 @@ addhstaiX (struct database_dyn *db, int @@ -284,13 +291,11 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
cfct = __nss_lookup_function (nip, "getcanonname_r"); cfct = __nss_lookup_function (nip, "getcanonname_r");
if (cfct != NULL) if (cfct != NULL)
{ {
@ -668,7 +598,7 @@ Index: b/nscd/aicache.c
== NSS_STATUS_SUCCESS) == NSS_STATUS_SUCCESS)
canon = s; canon = s;
else else
@@ -319,18 +324,20 @@ addhstaiX (struct database_dyn *db, int @@ -319,18 +324,20 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
addrfamily = AF_INET6; addrfamily = AF_INET6;
} }
@ -705,11 +635,11 @@ Index: b/nscd/aicache.c
return timeout; return timeout;
} }
Index: b/nscd/connections.c diff --git a/nscd/connections.c b/nscd/connections.c
=================================================================== index cc1ed72077640a8b..2f69800ee5ca83b4 100644
--- a/nscd/connections.c --- a/nscd/connections.c
+++ b/nscd/connections.c +++ b/nscd/connections.c
@@ -1324,64 +1324,83 @@ request from '%s' [%ld] not handled due @@ -1324,64 +1324,83 @@ request from '%s' [%ld] not handled due to missing permission"),
} }
} }
@ -729,20 +659,19 @@ Index: b/nscd/connections.c
- size_t readlen = 0; - size_t readlen = 0;
int fd = open ("/proc/self/cmdline", O_RDONLY); int fd = open ("/proc/self/cmdline", O_RDONLY);
- if (fd == -1) - if (fd == -1)
- {
- dbg_log (_("\
-cannot open /proc/self/cmdline: %s; disabling paranoia mode"),
- strerror (errno));
-
- paranoia = 0;
- return;
+ if (fd < 0) + if (fd < 0)
+ return NULL; + return NULL;
+ size_t current = 0; + size_t current = 0;
+ size_t limit = 1024; + size_t limit = 1024;
+ char *buffer = malloc (limit); + char *buffer = malloc (limit);
+ if (buffer == NULL) + if (buffer == NULL)
+ { {
- dbg_log (_("\
-cannot open /proc/self/cmdline: %s; disabling paranoia mode"),
- strerror (errno));
-
- paranoia = 0;
- return;
+ close (fd); + close (fd);
+ errno = ENOMEM; + errno = ENOMEM;
+ return NULL; + return NULL;
@ -832,7 +761,7 @@ Index: b/nscd/connections.c
{ {
argv[argc++] = cp; argv[argc++] = cp;
cp = (char *) rawmemchr (cp, '\0') + 1; cp = (char *) rawmemchr (cp, '\0') + 1;
@@ -1398,6 +1417,7 @@ cannot change to old UID: %s; disabling @@ -1398,6 +1417,7 @@ cannot change to old UID: %s; disabling paranoia mode"),
strerror (errno)); strerror (errno));
paranoia = 0; paranoia = 0;
@ -840,7 +769,7 @@ Index: b/nscd/connections.c
return; return;
} }
@@ -1409,6 +1429,7 @@ cannot change to old GID: %s; disabling @@ -1409,6 +1429,7 @@ cannot change to old GID: %s; disabling paranoia mode"),
ignore_value (setuid (server_uid)); ignore_value (setuid (server_uid));
paranoia = 0; paranoia = 0;
@ -848,7 +777,7 @@ Index: b/nscd/connections.c
return; return;
} }
} }
@@ -1426,6 +1447,7 @@ cannot change to old working directory: @@ -1426,6 +1447,7 @@ cannot change to old working directory: %s; disabling paranoia mode"),
ignore_value (setgid (server_gid)); ignore_value (setgid (server_gid));
} }
paranoia = 0; paranoia = 0;
@ -856,7 +785,7 @@ Index: b/nscd/connections.c
return; return;
} }
@@ -1474,6 +1496,7 @@ cannot change to old working directory: @@ -1474,6 +1496,7 @@ cannot change to old working directory: %s; disabling paranoia mode"),
dbg_log (_("cannot change current working directory to \"/\": %s"), dbg_log (_("cannot change current working directory to \"/\": %s"),
strerror (errno)); strerror (errno));
paranoia = 0; paranoia = 0;
@ -864,8 +793,8 @@ Index: b/nscd/connections.c
/* Reenable the databases. */ /* Reenable the databases. */
time_t now = time (NULL); time_t now = time (NULL);
Index: b/nscd/grpcache.c diff --git a/nscd/grpcache.c b/nscd/grpcache.c
=================================================================== index d2ad53509db97bdf..a71036512048dd81 100644
--- a/nscd/grpcache.c --- a/nscd/grpcache.c
+++ b/nscd/grpcache.c +++ b/nscd/grpcache.c
@@ -16,7 +16,6 @@ @@ -16,7 +16,6 @@
@ -884,7 +813,7 @@ Index: b/nscd/grpcache.c
#include "nscd.h" #include "nscd.h"
#include "dbg_log.h" #include "dbg_log.h"
@@ -448,12 +448,12 @@ addgrbyX (struct database_dyn *db, int f @@ -448,12 +448,12 @@ addgrbyX (struct database_dyn *db, int fd, request_header *req,
look again in the table whether the dataset is now available. We look again in the table whether the dataset is now available. We
simply insert it. It does not matter if it is in there twice. The simply insert it. It does not matter if it is in there twice. The
pruning function only will look at the timestamp. */ pruning function only will look at the timestamp. */
@ -900,7 +829,7 @@ Index: b/nscd/grpcache.c
if (__glibc_unlikely (debug_level > 0)) if (__glibc_unlikely (debug_level > 0))
{ {
@@ -463,43 +463,24 @@ addgrbyX (struct database_dyn *db, int f @@ -463,43 +463,24 @@ addgrbyX (struct database_dyn *db, int fd, request_header *req,
dbg_log (_("Reloading \"%s\" in group cache!"), keystr); dbg_log (_("Reloading \"%s\" in group cache!"), keystr);
} }
@ -959,8 +888,8 @@ Index: b/nscd/grpcache.c
return timeout; return timeout;
} }
Index: b/nscd/hstcache.c diff --git a/nscd/hstcache.c b/nscd/hstcache.c
=================================================================== index 9f6ce979ac333265..d0af99893dd17b9f 100644
--- a/nscd/hstcache.c --- a/nscd/hstcache.c
+++ b/nscd/hstcache.c +++ b/nscd/hstcache.c
@@ -34,6 +34,7 @@ @@ -34,6 +34,7 @@
@ -971,7 +900,7 @@ Index: b/nscd/hstcache.c
#include "nscd.h" #include "nscd.h"
#include "dbg_log.h" #include "dbg_log.h"
@@ -463,11 +464,8 @@ addhstbyX (struct database_dyn *db, int @@ -463,11 +464,8 @@ addhstbyX (struct database_dyn *db, int fd, request_header *req,
look again in the table whether the dataset is now available. We look again in the table whether the dataset is now available. We
simply insert it. It does not matter if it is in there twice. The simply insert it. It does not matter if it is in there twice. The
pruning function only will look at the timestamp. */ pruning function only will look at the timestamp. */
@ -983,7 +912,7 @@ Index: b/nscd/hstcache.c
int errval = 0; int errval = 0;
int32_t ttl = INT32_MAX; int32_t ttl = INT32_MAX;
@@ -487,46 +485,30 @@ addhstbyX (struct database_dyn *db, int @@ -487,46 +485,30 @@ addhstbyX (struct database_dyn *db, int fd, request_header *req,
dbg_log (_("Reloading \"%s\" in hosts cache!"), (char *) str); dbg_log (_("Reloading \"%s\" in hosts cache!"), (char *) str);
} }
@ -1049,8 +978,8 @@ Index: b/nscd/hstcache.c
return timeout; return timeout;
} }
Index: b/nscd/pwdcache.c diff --git a/nscd/pwdcache.c b/nscd/pwdcache.c
=================================================================== index 721f4c617b0bb74a..9349b54df4241ad5 100644
--- a/nscd/pwdcache.c --- a/nscd/pwdcache.c
+++ b/nscd/pwdcache.c +++ b/nscd/pwdcache.c
@@ -16,7 +16,6 @@ @@ -16,7 +16,6 @@
@ -1069,7 +998,7 @@ Index: b/nscd/pwdcache.c
#include "nscd.h" #include "nscd.h"
#include "dbg_log.h" #include "dbg_log.h"
@@ -426,12 +426,11 @@ addpwbyX (struct database_dyn *db, int f @@ -426,12 +426,11 @@ addpwbyX (struct database_dyn *db, int fd, request_header *req,
look again in the table whether the dataset is now available. We look again in the table whether the dataset is now available. We
simply insert it. It does not matter if it is in there twice. The simply insert it. It does not matter if it is in there twice. The
pruning function only will look at the timestamp. */ pruning function only will look at the timestamp. */
@ -1084,7 +1013,7 @@ Index: b/nscd/pwdcache.c
if (__glibc_unlikely (debug_level > 0)) if (__glibc_unlikely (debug_level > 0))
{ {
@@ -441,45 +440,26 @@ addpwbyX (struct database_dyn *db, int f @@ -441,45 +440,26 @@ addpwbyX (struct database_dyn *db, int fd, request_header *req,
dbg_log (_("Reloading \"%s\" in password cache!"), keystr); dbg_log (_("Reloading \"%s\" in password cache!"), keystr);
} }
@ -1145,8 +1074,8 @@ Index: b/nscd/pwdcache.c
return timeout; return timeout;
} }
Index: b/nscd/servicescache.c diff --git a/nscd/servicescache.c b/nscd/servicescache.c
=================================================================== index 131ba6ddcc1a5f7a..549e9a446816d760 100644
--- a/nscd/servicescache.c --- a/nscd/servicescache.c
+++ b/nscd/servicescache.c +++ b/nscd/servicescache.c
@@ -16,7 +16,6 @@ @@ -16,7 +16,6 @@
@ -1165,7 +1094,7 @@ Index: b/nscd/servicescache.c
#include "nscd.h" #include "nscd.h"
#include "dbg_log.h" #include "dbg_log.h"
@@ -374,12 +374,11 @@ addservbyX (struct database_dyn *db, int @@ -374,12 +374,11 @@ addservbyX (struct database_dyn *db, int fd, request_header *req,
look again in the table whether the dataset is now available. We look again in the table whether the dataset is now available. We
simply insert it. It does not matter if it is in there twice. The simply insert it. It does not matter if it is in there twice. The
pruning function only will look at the timestamp. */ pruning function only will look at the timestamp. */
@ -1180,7 +1109,7 @@ Index: b/nscd/servicescache.c
if (__glibc_unlikely (debug_level > 0)) if (__glibc_unlikely (debug_level > 0))
{ {
@@ -389,43 +388,24 @@ addservbyX (struct database_dyn *db, int @@ -389,43 +388,24 @@ addservbyX (struct database_dyn *db, int fd, request_header *req,
dbg_log (_("Reloading \"%s\" in services cache!"), key); dbg_log (_("Reloading \"%s\" in services cache!"), key);
} }
@ -1239,8 +1168,8 @@ Index: b/nscd/servicescache.c
return timeout; return timeout;
} }
Index: b/nss/getent.c diff --git a/nss/getent.c b/nss/getent.c
=================================================================== index 8f8c3fe80a2cfea6..5654c5f67c4f118c 100644
--- a/nss/getent.c --- a/nss/getent.c
+++ b/nss/getent.c +++ b/nss/getent.c
@@ -39,6 +39,7 @@ @@ -39,6 +39,7 @@
@ -1293,7 +1222,7 @@ Index: b/nss/getent.c
printf ("%-21s", key[i]); printf ("%-21s", key[i]);
for (int j = 0; j < n; ++j) for (int j = 0; j < n; ++j)
if (grps[j] != -1) if (grps[j] != -1)
@@ -508,6 +513,8 @@ initgroups_keys (int number, char *key[] @@ -508,6 +513,8 @@ initgroups_keys (int number, char *key[])
putchar_unlocked ('\n'); putchar_unlocked ('\n');
} }
@ -1302,111 +1231,79 @@ Index: b/nss/getent.c
return 0; return 0;
} }
Index: b/nss/nss_files/files-hosts.c diff --git a/nss/nss_compat/compat-initgroups.c b/nss/nss_compat/compat-initgroups.c
=================================================================== index c1a9301a3b0c3ee0..bae8765afbd109e9 100644
--- a/nss/nss_files/files-hosts.c --- a/nss/nss_compat/compat-initgroups.c
+++ b/nss/nss_files/files-hosts.c +++ b/nss/nss_compat/compat-initgroups.c
@@ -22,7 +22,7 @@ @@ -261,7 +261,6 @@ getgrent_next_nss (ent_t *ent, char *buffer, size_t buflen, const char *user,
#include <arpa/nameser.h> overwrite the pointer with one to a bigger buffer. */
#include <netdb.h> char *tmpbuf = buffer;
#include <resolv/resolv-internal.h> size_t tmplen = buflen;
- - bool use_malloc = false;
+#include <scratch_buffer.h>
/* Get implementation for some internal functions. */ for (int i = 0; i < mystart; i++)
#include "../resolv/mapv4v6addr.h"
@@ -145,15 +145,12 @@ _nss_files_gethostbyname3_r (const char
&& _res_hconf.flags & HCONF_FLAG_MULTI)
{ {
/* We have to get all host entries from the file. */ @@ -270,29 +269,26 @@ getgrent_next_nss (ent_t *ent, char *buffer, size_t buflen, const char *user,
- size_t tmp_buflen = MIN (buflen, 4096); == NSS_STATUS_TRYAGAIN
- char tmp_buffer_stack[tmp_buflen] && *errnop == ERANGE)
- __attribute__ ((__aligned__ (__alignof__ (struct hostent_data))));
- char *tmp_buffer = tmp_buffer_stack;
struct hostent tmp_result_buf;
int naddrs = 1;
int naliases = 0;
char *bufferend;
- bool tmp_buffer_malloced = false;
+ struct scratch_buffer tmpbuf;
+ scratch_buffer_init (&tmpbuf);
while (result->h_aliases[naliases] != NULL)
++naliases;
@@ -161,9 +158,9 @@ _nss_files_gethostbyname3_r (const char
bufferend = (char *) &result->h_aliases[naliases + 1];
again:
- while ((status = internal_getent (stream, &tmp_result_buf, tmp_buffer,
- tmp_buflen, errnop, herrnop, af,
- flags))
+ while ((status = internal_getent (stream, &tmp_result_buf,
+ tmpbuf.data, tmpbuf.length,
+ errnop, herrnop, af, flags))
== NSS_STATUS_SUCCESS)
{ {
int matches = 1; - if (__libc_use_alloca (tmplen * 2))
@@ -287,54 +284,13 @@ _nss_files_gethostbyname3_r (const char
}
}
- if (status == NSS_STATUS_TRYAGAIN)
- { - {
- size_t newsize = 2 * tmp_buflen; - if (tmpbuf == buffer)
- if (tmp_buffer_malloced)
- { - {
- char *newp = realloc (tmp_buffer, newsize); - tmplen *= 2;
- if (newp != NULL) - tmpbuf = __alloca (tmplen);
- {
- assert ((((uintptr_t) newp)
- & (__alignof__ (struct hostent_data) - 1))
- == 0);
- tmp_buffer = newp;
- tmp_buflen = newsize;
- goto again;
- }
- }
- else if (!__libc_use_alloca (buflen + newsize))
- {
- tmp_buffer = malloc (newsize);
- if (tmp_buffer != NULL)
- {
- assert ((((uintptr_t) tmp_buffer)
- & (__alignof__ (struct hostent_data) - 1))
- == 0);
- tmp_buffer_malloced = true;
- tmp_buflen = newsize;
- goto again;
- } - }
- else
- tmpbuf = extend_alloca (tmpbuf, tmplen, tmplen * 2);
- } - }
- else - else
- { - {
- tmp_buffer - tmplen *= 2;
- = extend_alloca (tmp_buffer, tmp_buflen, - char *newbuf = realloc (use_malloc ? tmpbuf : NULL, tmplen);
- newsize -
- + __alignof__ (struct hostent_data)); - if (newbuf == NULL)
- tmp_buffer = (char *) (((uintptr_t) tmp_buffer - {
- + __alignof__ (struct hostent_data) - status = NSS_STATUS_TRYAGAIN;
- - 1) - goto done;
- & ~(__alignof__ (struct hostent_data)
- - 1));
- goto again;
- } - }
- use_malloc = true;
- tmpbuf = newbuf;
- } - }
+ if (status == NSS_STATUS_TRYAGAIN + /* Check for overflow. */
+ && scratch_buffer_grow (&tmpbuf)) + if (__glibc_unlikely (tmplen * 2 < tmplen))
+ goto again; + {
else + __set_errno (ENOMEM);
status = NSS_STATUS_SUCCESS; + status = NSS_STATUS_TRYAGAIN;
out: + goto done;
- if (tmp_buffer_malloced) + }
- free (tmp_buffer); + /* Increase the size. Make sure that we retry
+ scratch_buffer_free (&tmpbuf); + with a reasonable size. */
+ tmplen *= 2;
+ if (tmplen < 1024)
+ tmplen = 1024;
+ if (tmpbuf != buffer)
+ free (tmpbuf);
+ tmpbuf = malloc (tmplen);
+ if (__glibc_unlikely (tmpbuf == NULL))
+ {
+ status = NSS_STATUS_TRYAGAIN;
+ goto done;
+ }
} }
internal_endent (&stream); if (__builtin_expect (status != NSS_STATUS_NOTFOUND, 1))
Index: b/nss/nss_files/files-initgroups.c @@ -320,7 +316,7 @@ getgrent_next_nss (ent_t *ent, char *buffer, size_t buflen, const char *user,
=================================================================== status = NSS_STATUS_NOTFOUND;
done:
- if (use_malloc)
+ if (tmpbuf != buffer)
free (tmpbuf);
}
diff --git a/nss/nss_files/files-initgroups.c b/nss/nss_files/files-initgroups.c
index 27cd8ece40434f5c..8a88f1b62357d3bd 100644
--- a/nss/nss_files/files-initgroups.c --- a/nss/nss_files/files-initgroups.c
+++ b/nss/nss_files/files-initgroups.c +++ b/nss/nss_files/files-initgroups.c
@@ -16,7 +16,6 @@ @@ -16,7 +16,6 @@
@ -1425,7 +1322,7 @@ Index: b/nss/nss_files/files-initgroups.c
enum nss_status enum nss_status
_nss_files_initgroups_dyn (const char *user, gid_t group, long int *start, _nss_files_initgroups_dyn (const char *user, gid_t group, long int *start,
@@ -46,9 +46,8 @@ _nss_files_initgroups_dyn (const char *u @@ -46,9 +46,8 @@ _nss_files_initgroups_dyn (const char *user, gid_t group, long int *start,
enum nss_status status = NSS_STATUS_SUCCESS; enum nss_status status = NSS_STATUS_SUCCESS;
bool any = false; bool any = false;
@ -1437,7 +1334,7 @@ Index: b/nss/nss_files/files-initgroups.c
gid_t *groups = *groupsp; gid_t *groups = *groupsp;
@@ -67,26 +66,16 @@ _nss_files_initgroups_dyn (const char *u @@ -67,26 +66,16 @@ _nss_files_initgroups_dyn (const char *user, gid_t group, long int *start,
} }
struct group grp; struct group grp;
@ -1470,7 +1367,7 @@ Index: b/nss/nss_files/files-initgroups.c
/* Reread current line, the parser has clobbered it. */ /* Reread current line, the parser has clobbered it. */
fsetpos (stream, &pos); fsetpos (stream, &pos);
continue; continue;
@@ -132,8 +121,7 @@ _nss_files_initgroups_dyn (const char *u @@ -132,8 +121,7 @@ _nss_files_initgroups_dyn (const char *user, gid_t group, long int *start,
out: out:
/* Free memory. */ /* Free memory. */
@ -1480,8 +1377,8 @@ Index: b/nss/nss_files/files-initgroups.c
free (line); free (line);
fclose (stream); fclose (stream);
Index: b/posix/wordexp.c diff --git a/posix/wordexp.c b/posix/wordexp.c
=================================================================== index e4cfce946013dc78..a751fb32b286aec2 100644
--- a/posix/wordexp.c --- a/posix/wordexp.c
+++ b/posix/wordexp.c +++ b/posix/wordexp.c
@@ -17,7 +17,6 @@ @@ -17,7 +17,6 @@
@ -1500,7 +1397,7 @@ Index: b/posix/wordexp.c
#include <libc-lock.h> #include <libc-lock.h>
#include <_itoa.h> #include <_itoa.h>
@@ -308,12 +308,7 @@ parse_tilde (char **word, size_t *word_l @@ -299,12 +299,7 @@ parse_tilde (char **word, size_t *word_length, size_t *max_length,
if (i == 1 + *offset) if (i == 1 + *offset)
{ {
/* Tilde appears on its own */ /* Tilde appears on its own */
@ -1513,7 +1410,7 @@ Index: b/posix/wordexp.c
/* POSIX.2 says ~ expands to $HOME and if HOME is unset the /* POSIX.2 says ~ expands to $HOME and if HOME is unset the
results are unspecified. We do a lookup on the uid if results are unspecified. We do a lookup on the uid if
@@ -328,25 +323,38 @@ parse_tilde (char **word, size_t *word_l @@ -319,25 +314,38 @@ parse_tilde (char **word, size_t *word_length, size_t *max_length,
} }
else else
{ {
@ -1559,7 +1456,7 @@ Index: b/posix/wordexp.c
} }
} }
else else
@@ -354,13 +362,15 @@ parse_tilde (char **word, size_t *word_l @@ -345,13 +353,15 @@ parse_tilde (char **word, size_t *word_length, size_t *max_length,
/* Look up user name in database to get home directory */ /* Look up user name in database to get home directory */
char *user = strndupa (&words[1 + *offset], i - (1 + *offset)); char *user = strndupa (&words[1 + *offset], i - (1 + *offset));
struct passwd pwd, *tpwd; struct passwd pwd, *tpwd;
@ -1579,7 +1476,7 @@ Index: b/posix/wordexp.c
if (result == 0 && tpwd != NULL && pwd.pw_dir) if (result == 0 && tpwd != NULL && pwd.pw_dir)
*word = w_addstr (*word, word_length, max_length, pwd.pw_dir); *word = w_addstr (*word, word_length, max_length, pwd.pw_dir);
@@ -372,6 +382,8 @@ parse_tilde (char **word, size_t *word_l @@ -363,6 +373,8 @@ parse_tilde (char **word, size_t *word_length, size_t *max_length,
*word = w_addstr (*word, word_length, max_length, user); *word = w_addstr (*word, word_length, max_length, user);
} }
@ -1588,8 +1485,8 @@ Index: b/posix/wordexp.c
*offset = i - 1; *offset = i - 1;
} }
return *word ? 0 : WRDE_NOSPACE; return *word ? 0 : WRDE_NOSPACE;
Index: b/sysdeps/unix/sysv/linux/gethostid.c diff --git a/sysdeps/unix/sysv/linux/gethostid.c b/sysdeps/unix/sysv/linux/gethostid.c
=================================================================== index ca0387723873aa8c..9a9346c2189acf7a 100644
--- a/sysdeps/unix/sysv/linux/gethostid.c --- a/sysdeps/unix/sysv/linux/gethostid.c
+++ b/sysdeps/unix/sysv/linux/gethostid.c +++ b/sysdeps/unix/sysv/linux/gethostid.c
@@ -63,13 +63,12 @@ sethostid (long int id) @@ -63,13 +63,12 @@ sethostid (long int id)
@ -1642,8 +1539,8 @@ Index: b/sysdeps/unix/sysv/linux/gethostid.c
/* For the return value to be not exactly the IP address we do some /* For the return value to be not exactly the IP address we do some
bit fiddling. */ bit fiddling. */
return (int32_t) (in.s_addr << 16 | in.s_addr >> 16); return (int32_t) (in.s_addr << 16 | in.s_addr >> 16);
Index: b/sysdeps/unix/sysv/linux/getlogin_r.c diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
=================================================================== index 45c468f5a13529d8..fea3e18b1bc30ee7 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c --- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c +++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
@ -1654,7 +1551,7 @@ Index: b/sysdeps/unix/sysv/linux/getlogin_r.c
#define STATIC static #define STATIC static
static int getlogin_r_fd0 (char *name, size_t namesize); static int getlogin_r_fd0 (char *name, size_t namesize);
@@ -54,28 +55,19 @@ __getlogin_r_loginuid (char *name, size_ @@ -54,28 +55,19 @@ __getlogin_r_loginuid (char *name, size_t namesize)
endp == uidbuf || *endp != '\0')) endp == uidbuf || *endp != '\0'))
return -1; return -1;
@ -1690,7 +1587,7 @@ Index: b/sysdeps/unix/sysv/linux/getlogin_r.c
} }
if (res != 0 || tpwd == NULL) if (res != 0 || tpwd == NULL)
@@ -95,9 +87,7 @@ __getlogin_r_loginuid (char *name, size_ @@ -95,9 +87,7 @@ __getlogin_r_loginuid (char *name, size_t namesize)
memcpy (name, pwd.pw_name, needed); memcpy (name, pwd.pw_name, needed);
out: out:

View File

@ -1,6 +1,6 @@
%define glibcsrcdir glibc-2.26-543-g645ac9aaf8 %define glibcsrcdir glibc-2.26-553-gd8425e116c
%define glibcversion 2.26.90 %define glibcversion 2.26.90
%define glibcrelease 19%{?dist} %define glibcrelease 20%{?dist}
# Pre-release tarballs are pulled in from git using a command that is # Pre-release tarballs are pulled in from git using a command that is
# effectively: # effectively:
# #
@ -2116,6 +2116,12 @@ fi
%endif %endif
%changelog %changelog
* Wed Oct 11 2017 Florian Weimer <fweimer@redhat.com> - 2.26.90-20
- Auto-sync with upstream branch master,
commit d8425e116cdd954fea0c04c0f406179b5daebbb3:
- nss_files performance issue in multi mode (swbz#22078)
- Ensure C99 and C11 interfaces are available for C++ (swbz#21326)
* Mon Oct 09 2017 Florian Weimer <fweimer@redhat.com> - 2.26.90-19 * Mon Oct 09 2017 Florian Weimer <fweimer@redhat.com> - 2.26.90-19
- Move /var/db/Makefile to nss_db (#1498900) - Move /var/db/Makefile to nss_db (#1498900)
- Auto-sync with upstream branch master, - Auto-sync with upstream branch master,

View File

@ -1 +1 @@
SHA512 (glibc-2.26-543-g645ac9aaf8.tar.gz) = ded33961468daccde0bf155e5534e015ad092ccc4c302febed086e9966dcc2f373e3b3c9c329d8babf2e26a6f3c96ec3c9efab0a8275b84eedad2ab13db7d347 SHA512 (glibc-2.26-553-gd8425e116c.tar.gz) = e54c68a352f02405285eedaacdc64f69be2cc221583a5ddc1ecc226eb58b4ba566f4078847c2816eaf02112245eceb53cd20aaf504300997885590afa1706824