Skip to content

Commit

Permalink
* resolv/res_query.c (__libc_res_nquery): In case one of two
Browse files Browse the repository at this point in the history
	answer was too short don't try to read that answer's header.

	* resolv/res_send.c (send_dg): In case of timeout and there are
	two queries and one has been answered, return value indicating
	success.
  • Loading branch information
Ulrich Drepper committed May 19, 2008
1 parent 528741c commit 5908f77
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
2008-05-19 Ulrich Drepper <drepper@redhat.com>

* resolv/res_query.c (__libc_res_nquery): In case one of two
answer was too short don't try to read that answer's header.

* resolv/res_send.c (send_dg): In case of timeout and there are
two queries and one has been answered, return value indicating
success.

2008-05-18 Ulrich Drepper <drepper@redhat.com>

* nscd/cache.c (cache_add): Take additional parameter specifying
Expand Down
15 changes: 15 additions & 0 deletions resolv/res_query.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,21 @@ __libc_res_nquery(res_state statp,
tests of HP2. */
HEADER *hp2 = answerp2 ? (HEADER *) *answerp2 : hp;

if (n < sizeof (HEADER) && nanswerp2 != NULL
&& *nanswerp2 > sizeof (HEADER))
{
/* Special case of partial answer. */
assert (hp != hp2);
hp = hp2;
}
else if (nanswerp2 != NULL
&& *nanswerp2 < sizeof (HEADER) && n > sizeof (HEADER))
{
/* Special case of partial answer. */
assert (hp != hp2);
hp2 = hp;
}

if ((hp->rcode != NOERROR || ntohs(hp->ancount) == 0)
&& (hp2->rcode != NOERROR || ntohs(hp2->ancount) == 0)) {
#ifdef DEBUG
Expand Down
7 changes: 7 additions & 0 deletions resolv/res_send.c
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,8 @@ send_dg(res_state statp,
int recvresp2 = buf2 == NULL;
pfd[0].fd = EXT(statp).nssocks[ns];
pfd[0].events = POLLOUT;
if (resplen2 != NULL)
*resplen2 = 0;
wait:
if (need_recompute) {
recompute_resend:
Expand All @@ -1001,6 +1003,11 @@ send_dg(res_state statp,
if (n == 0) {
Dprint(statp->options & RES_DEBUG, (stdout,
";; timeout sending\n"));
if (recvresp1)
return resplen;
if (buf2 != NULL && recvresp2)
return 1;

*gotsomewhere = 1;
return (0);
}
Expand Down

0 comments on commit 5908f77

Please sign in to comment.