about summary refs log tree commit diff
path: root/resolv/res_send.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-05-30 22:48:47 -0400
committerUlrich Drepper <drepper@gmail.com>2011-05-30 22:48:47 -0400
commit4769ae77fc6c8dacea6476addb015c8797848cdd (patch)
tree23dcf208109df183c6b4c1819e2101166176e614 /resolv/res_send.c
parent4462fad3d9db8c5d5c842b059edefa0019a5e045 (diff)
downloadglibc-4769ae77fc6c8dacea6476addb015c8797848cdd.tar.gz
glibc-4769ae77fc6c8dacea6476addb015c8797848cdd.tar.xz
glibc-4769ae77fc6c8dacea6476addb015c8797848cdd.zip
Handle DNS server failures in case of AF_UNSPEC lookups correctly
Diffstat (limited to 'resolv/res_send.c')
-rw-r--r--resolv/res_send.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/resolv/res_send.c b/resolv/res_send.c
index 845b658e36..97142b7dd0 100644
--- a/resolv/res_send.c
+++ b/resolv/res_send.c
@@ -549,7 +549,7 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen,
 				    ns, ansp, ansp2, nansp2, resplen2);
 			if (n < 0)
 				return (-1);
-			if (n == 0)
+			if (n == 0 && (buf2 == NULL || resplen2 == 0))
 				goto next_ns;
 		} else {
 			/* Use datagrams. */
@@ -559,7 +559,7 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen,
 				    ansp2, nansp2, resplen2);
 			if (n < 0)
 				return (-1);
-			if (n == 0)
+			if (n == 0 && (buf2 == NULL || resplen2 == 0))
 				goto next_ns;
 			if (v_circuit)
 			  // XXX Check whether both requests failed or
@@ -1275,10 +1275,14 @@ send_dg(res_state statp,
 				(*thisresplenp > *thisanssizp)
 				? *thisanssizp : *thisresplenp);
 
-			if (recvresp1 || (buf2 != NULL && recvresp2))
+			if (recvresp1 || (buf2 != NULL && recvresp2)) {
+			  *resplen2 = 0;
 			  return resplen;
+			}
 			if (buf2 != NULL)
 			  {
+			    /* No data from the first reply.  */
+			    resplen = 0;
 			    /* We are waiting for a possible second reply.  */
 			    if (hp->id == anhp->id)
 			      recvresp1 = 1;
@@ -1344,7 +1348,7 @@ send_dg(res_state statp,
 		goto err_out;
 	}
 	else {
-	  	/* poll should not have returned > 0 in this case.  */
+		/* poll should not have returned > 0 in this case.  */
 		abort ();
 	}
 }