2001-12-11  Ulrich Drepper  <drepper@redhat.com>

	* resolv/nss_dns/dns-host.c (getanswer_r): Remove MAX_NR_ADDRS
	limitation [PR libc/2564].
This commit is contained in:
Ulrich Drepper 2001-12-12 07:38:32 +00:00
parent c17f665ba8
commit 88a96b8102
2 changed files with 11 additions and 9 deletions

View File

@ -1,3 +1,8 @@
2001-12-11 Ulrich Drepper <drepper@redhat.com>
* resolv/nss_dns/dns-host.c (getanswer_r): Remove MAX_NR_ADDRS
limitation [PR libc/2564].
2001-12-11 Jakub Jelinek <jakub@redhat.com> 2001-12-11 Jakub Jelinek <jakub@redhat.com>
* elf/Makefile (dl-routines): Add conflict. * elf/Makefile (dl-routines): Add conflict.

View File

@ -387,10 +387,9 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype,
{ {
char *aliases[MAX_NR_ALIASES]; char *aliases[MAX_NR_ALIASES];
unsigned char host_addr[16]; /* IPv4 or IPv6 */ unsigned char host_addr[16]; /* IPv4 or IPv6 */
char *h_addr_ptrs[MAX_NR_ADDRS + 1]; char *h_addr_ptrs[0];
char linebuffer[0];
} *host_data = (struct host_data *) buffer; } *host_data = (struct host_data *) buffer;
int linebuflen = buflen - offsetof (struct host_data, linebuffer); int linebuflen = buflen - sizeof (struct host_data);
register const HEADER *hp; register const HEADER *hp;
const u_char *end_of_message, *cp; const u_char *end_of_message, *cp;
int n, ancount, qdcount; int n, ancount, qdcount;
@ -432,7 +431,6 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype,
* find first satisfactory answer * find first satisfactory answer
*/ */
hp = &answer->hdr; hp = &answer->hdr;
bp = host_data->linebuffer;
ancount = ntohs (hp->ancount); ancount = ntohs (hp->ancount);
qdcount = ntohs (hp->qdcount); qdcount = ntohs (hp->qdcount);
cp = answer->buf + HFIXEDSZ; cp = answer->buf + HFIXEDSZ;
@ -442,6 +440,10 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype,
*errnop = ENOENT; *errnop = ENOENT;
return NSS_STATUS_UNAVAIL; return NSS_STATUS_UNAVAIL;
} }
if (sizeof (struct host_data) + (ancount + 1) * sizeof (char *) >= buflen)
goto too_small;
bp = (char *) &host_data->h_addr_ptrs[ancount + 1];
linebuflen -= (ancount + 1) * sizeof (char *);
n = __ns_name_unpack (answer->buf, end_of_message, cp, n = __ns_name_unpack (answer->buf, end_of_message, cp,
packtmp, sizeof packtmp); packtmp, sizeof packtmp);
@ -701,11 +703,6 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype,
if (__builtin_expect (n > linebuflen, 0)) if (__builtin_expect (n > linebuflen, 0))
goto too_small; goto too_small;
if (hap >= &host_data->h_addr_ptrs[MAX_NR_ADDRS-1])
{
cp += n;
continue;
}
bp = __mempcpy (*hap++ = bp, cp, n); bp = __mempcpy (*hap++ = bp, cp, n);
cp += n; cp += n;
linebuflen -= n; linebuflen -= n;