about summary refs log tree commit diff
path: root/resolv/res_query.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2008-05-19 17:34:14 +0000
committerUlrich Drepper <drepper@redhat.com>2008-05-19 17:34:14 +0000
commit5908f779e76e24827c0c6f38f2b7a0f857333bcb (patch)
treefe2afd890ce08267486077d80eee52935e854c3d /resolv/res_query.c
parent528741cb6c7218e7f2f764fa10aa7e67699eadaa (diff)
downloadglibc-5908f779e76e24827c0c6f38f2b7a0f857333bcb.tar.gz
glibc-5908f779e76e24827c0c6f38f2b7a0f857333bcb.tar.xz
glibc-5908f779e76e24827c0c6f38f2b7a0f857333bcb.zip
* 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.
Diffstat (limited to 'resolv/res_query.c')
-rw-r--r--resolv/res_query.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/resolv/res_query.c b/resolv/res_query.c
index a8e8d7b739..3d2f2fe3a9 100644
--- a/resolv/res_query.c
+++ b/resolv/res_query.c
@@ -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