+2010-04-09 Ulrich Drepper <drepper@redhat.com>
+
+ * nscd/aicache.c (addhstaiX): Correct passing memory to address
+ list to gethostbyname4_r functions.
+
+ * resolv/nss_dns/dns-host.c (gaih_getanswer_slice): Optimize
+ copying of h_name.
+
2010-04-09 Roland McGrath <roland@redhat.com>
* Makerules ($(common-objpfx)libc-abis.h): Depend on libc-abis.stamp.
/* Cache handling for host lookup.
- Copyright (C) 2004-2008, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2004-2008, 2009, 2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
int old_res_options = _res.options;
_res.options &= ~RES_USE_INET6;
- size_t tmpbuf6len = 512;
+ size_t tmpbuf6len = 1024;
char *tmpbuf6 = alloca (tmpbuf6len);
size_t tmpbuf4len = 0;
char *tmpbuf4 = NULL;
"gethostbyname4_r");
if (fct4 != NULL)
{
- struct gaih_addrtuple *at = NULL;
+ struct gaih_addrtuple atmem;
+ struct gaih_addrtuple *at;
while (1)
{
+ at = &atmem;
rc6 = 0;
herrno = 0;
status[1] = DL_CALL_FCT (fct4, (key, &at, tmpbuf6, tmpbuf6len,
goto next_nip;
/* We found the data. Count the addresses and the size. */
- for (const struct gaih_addrtuple *at2 = at; at2 != NULL;
+ for (const struct gaih_addrtuple *at2 = at = &atmem; at2 != NULL;
at2 = at2->next)
{
++naddrs;
++had_error;
continue;
}
- if (*firstp)
+ if (*firstp && canon == NULL)
{
h_name = buffer;
buffer += h_namelen;
if (ttl != 0 && ttlp != NULL)
*ttlp = ttl;
- if (canon != NULL)
- {
- (*pat)->name = canon;
-
- /* Reclaim buffer space. */
- if (h_name + h_namelen == buffer)
- {
- buffer = h_name;
- buflen += h_namelen;
- }
- }
- else
- (*pat)->name = h_name;
+ (*pat)->name = canon ?: h_name;
*firstp = 0;
}