aboutsummaryrefslogtreecommitdiff
path: root/resolv/res_query.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2008-07-28 22:55:10 +0000
committerUlrich Drepper <drepper@redhat.com>2008-07-28 22:55:10 +0000
commitb7da31a1647e378258174d1d69097a594e31f89b (patch)
treea38031232a20545f6c044a94f6823ecfb6090ead /resolv/res_query.c
parent372aece0e4b7497f894f21b36bcc32ec52344ad5 (diff)
downloadglibc-b7da31a1647e378258174d1d69097a594e31f89b.tar
glibc-b7da31a1647e378258174d1d69097a594e31f89b.tar.gz
glibc-b7da31a1647e378258174d1d69097a594e31f89b.tar.bz2
glibc-b7da31a1647e378258174d1d69097a594e31f89b.zip
* resolv/res_send.c (__libc_res_nsend): Take additional parameter.cvs/fedora-glibc-20080728T2320
Use it instead of locally defined resplen2 variable. (res_nsend): Adjust for __libc_res_nsend interface change. (send_vc): Initialize *resplen2 if necessary. Read length of package into an appropriately aligned variable. Store converted length in new variable and use it appropriately. Add branch prediction help. * resolv/res_query.c (__libc_res_nquery): Take additional parameter and pass it on to __libc_res_nsend. Adjust all callers. (__libc_res_nsearch): Likewise. (__libc_res_nqeurydomain): Likewise. * resolv/nss_dns/dns-host.c: Adjust for __libc_res_nsearch interface change. (_nss_dns_gethostbyname4): Don't unconditionally allocate tmp array. Define resplen2 variable and pass it to __libc_res_nsearch and then to gaih_getanswer. (getanswer_r): In case of incorrect DNS data don't overread buffer. Add branch prediction. (gaih_getanswer_slice): Likewise. Check for invalid data types. (gaih_getanswer): Don't decode second slice if first one failed due to a too small buffer. Don't let not found status of second decoder shadow results of the first. * resolv/gethnamaddr.c (gethostbyname2): Adjust for __libc_res_nsearch and __libc_res_nquery interface changes (gethostbyaddr): Adjust for __libc_res_nquery interface change. * include/resolv.h: Adjust prototypes for __libc_res_nquery, __libc_res_nsearch, and __libc_res_nsend. * resolv/nss_dns/dns-canon.c: Adjust for __libc_res_nquery interface change. * resolv/nss_dns/dns-network.c: Adjust for __libc_res_nquery and __libc_res_nsearch interface changes.
Diffstat (limited to 'resolv/res_query.c')
-rw-r--r--resolv/res_query.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/resolv/res_query.c b/resolv/res_query.c
index b2b45acde7..7102ba948e 100644
--- a/resolv/res_query.c
+++ b/resolv/res_query.c
@@ -97,7 +97,8 @@ static const char rcsid[] = "$BINDId: res_query.c,v 8.20 2000/02/29 05:39:12 vix
static int
__libc_res_nquerydomain(res_state statp, const char *name, const char *domain,
int class, int type, u_char *answer, int anslen,
- u_char **answerp, u_char **answerp2, int *nanswerp2);
+ u_char **answerp, u_char **answerp2, int *nanswerp2,
+ int *resplen2);
/*
* Formulate a normal query, send, and await answer.
@@ -117,7 +118,8 @@ __libc_res_nquery(res_state statp,
int anslen, /* size of answer buffer */
u_char **answerp, /* if buffer needs to be enlarged */
u_char **answerp2,
- int *nanswerp2)
+ int *nanswerp2,
+ int *resplen2)
{
HEADER *hp = (HEADER *) answer;
int n, use_malloc = 0;
@@ -221,7 +223,7 @@ __libc_res_nquery(res_state statp,
}
assert (answerp == NULL || (void *) *answerp == (void *) answer);
n = __libc_res_nsend(statp, query1, nquery1, query2, nquery2, answer,
- anslen, answerp, answerp2, nanswerp2);
+ anslen, answerp, answerp2, nanswerp2, resplen2);
if (use_malloc)
free (buf);
if (n < 0) {
@@ -307,7 +309,7 @@ res_nquery(res_state statp,
int anslen) /* size of answer buffer */
{
return __libc_res_nquery(statp, name, class, type, answer, anslen,
- NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL);
}
libresolv_hidden_def (res_nquery)
@@ -325,7 +327,8 @@ __libc_res_nsearch(res_state statp,
int anslen, /* size of answer */
u_char **answerp,
u_char **answerp2,
- int *nanswerp2)
+ int *nanswerp2,
+ int *resplen2)
{
const char *cp, * const *domain;
HEADER *hp = (HEADER *) answer;
@@ -349,7 +352,7 @@ __libc_res_nsearch(res_state statp,
if (!dots && (cp = res_hostalias(statp, name, tmp, sizeof tmp))!= NULL)
return (__libc_res_nquery(statp, cp, class, type, answer,
anslen, answerp, answerp2,
- nanswerp2));
+ nanswerp2, resplen2));
#ifdef DEBUG
if (statp->options & RES_DEBUG)
@@ -366,7 +369,7 @@ __libc_res_nsearch(res_state statp,
if (dots >= statp->ndots || trailing_dot) {
ret = __libc_res_nquerydomain(statp, name, NULL, class, type,
answer, anslen, answerp,
- answerp2, nanswerp2);
+ answerp2, nanswerp2, resplen2);
if (ret > 0 || trailing_dot)
return (ret);
saved_herrno = h_errno;
@@ -404,7 +407,8 @@ __libc_res_nsearch(res_state statp,
ret = __libc_res_nquerydomain(statp, name, *domain,
class, type,
answer, anslen, answerp,
- answerp2, nanswerp2);
+ answerp2, nanswerp2,
+ resplen2);
if (ret > 0)
return (ret);
@@ -473,7 +477,7 @@ __libc_res_nsearch(res_state statp,
if (dots && !(tried_as_is || root_on_list)) {
ret = __libc_res_nquerydomain(statp, name, NULL, class, type,
answer, anslen, answerp,
- answerp2, nanswerp2);
+ answerp2, nanswerp2, resplen2);
if (ret > 0)
return (ret);
}
@@ -508,7 +512,7 @@ res_nsearch(res_state statp,
int anslen) /* size of answer */
{
return __libc_res_nsearch(statp, name, class, type, answer,
- anslen, NULL, NULL, NULL);
+ anslen, NULL, NULL, NULL, NULL);
}
libresolv_hidden_def (res_nsearch)
@@ -525,7 +529,8 @@ __libc_res_nquerydomain(res_state statp,
int anslen, /* size of answer */
u_char **answerp,
u_char **answerp2,
- int *nanswerp2)
+ int *nanswerp2,
+ int *resplen2)
{
char nbuf[MAXDNAME];
const char *longname = nbuf;
@@ -562,7 +567,8 @@ __libc_res_nquerydomain(res_state statp,
sprintf(nbuf, "%s.%s", name, domain);
}
return (__libc_res_nquery(statp, longname, class, type, answer,
- anslen, answerp, answerp2, nanswerp2));
+ anslen, answerp, answerp2, nanswerp2,
+ resplen2));
}
int
@@ -574,7 +580,7 @@ res_nquerydomain(res_state statp,
int anslen) /* size of answer */
{
return __libc_res_nquerydomain(statp, name, domain, class, type,
- answer, anslen, NULL, NULL, NULL);
+ answer, anslen, NULL, NULL, NULL, NULL);
}
libresolv_hidden_def (res_nquerydomain)