1 --- a/resolv/res_query.c
2 +++ b/resolv/res_query.c
3 @@ -122,6 +122,7 @@ __libc_res_nquery(res_state statp,
6 HEADER *hp = (HEADER *) answer;
9 u_int oflags = statp->_flags;
11 @@ -239,26 +240,25 @@ __libc_res_nquery(res_state statp,
12 /* __libc_res_nsend might have reallocated the buffer. */
13 hp = (HEADER *) *answerp;
15 - /* We simplify the following tests by assigning HP to HP2. It
16 - is easy to verify that this is the same as ignoring all
18 - HEADER *hp2 = answerp2 ? (HEADER *) *answerp2 : hp;
20 - if (n < (int) sizeof (HEADER) && answerp2 != NULL
21 - && *resplen2 > (int) sizeof (HEADER))
22 + /* We simplify the following tests by assigning HP to HP2 or
23 + vice versa. It is easy to verify that this is the same as
24 + ignoring all tests of HP or HP2. */
25 + if (answerp2 == NULL || *resplen2 < (int) sizeof (HEADER))
27 - /* Special case of partial answer. */
32 - else if (answerp2 != NULL && *resplen2 < (int) sizeof (HEADER)
33 - && n > (int) sizeof (HEADER))
36 - /* Special case of partial answer. */
39 + hp2 = (HEADER *) *answerp2;
40 + if (n < (int) sizeof (HEADER))
46 + /* Make sure both hp and hp2 are defined */
47 + assert((hp != NULL) && (hp2 != NULL));
49 if ((hp->rcode != NOERROR || ntohs(hp->ancount) == 0)
50 && (hp2->rcode != NOERROR || ntohs(hp2->ancount) == 0)) {