(__libc_res_nquery): In case one of two answer was too short don't try
authordrepper <drepper>
Mon, 19 May 2008 17:34:04 +0000 (17:34 +0000)
committerdrepper <drepper>
Mon, 19 May 2008 17:34:04 +0000 (17:34 +0000)
to read that answer's header.

resolv/res_query.c

index a8e8d7b..3d2f2fe 100644 (file)
@@ -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