|
Lines 122-127
__libc_res_nquery(res_state statp,
|
Link Here
|
|---|
|
| 122 |
int *resplen2) |
122 |
int *resplen2) |
| 123 |
{ |
123 |
{ |
| 124 |
HEADER *hp = (HEADER *) answer; |
124 |
HEADER *hp = (HEADER *) answer; |
|
|
125 |
HEADER *hp2; |
| 125 |
int n, use_malloc = 0; |
126 |
int n, use_malloc = 0; |
| 126 |
u_int oflags = statp->_flags; |
127 |
u_int oflags = statp->_flags; |
| 127 |
|
128 |
|
|
Lines 239-264
__libc_res_nquery(res_state statp,
|
Link Here
|
|---|
|
| 239 |
/* __libc_res_nsend might have reallocated the buffer. */ |
240 |
/* __libc_res_nsend might have reallocated the buffer. */ |
| 240 |
hp = (HEADER *) *answerp; |
241 |
hp = (HEADER *) *answerp; |
| 241 |
|
242 |
|
| 242 |
/* We simplify the following tests by assigning HP to HP2. It |
243 |
/* We simplify the following tests by assigning HP to HP2 or |
| 243 |
is easy to verify that this is the same as ignoring all |
244 |
vice versa. It is easy to verify that this is the same as |
| 244 |
tests of HP2. */ |
245 |
ignoring all tests of HP or HP2. */ |
| 245 |
HEADER *hp2 = answerp2 ? (HEADER *) *answerp2 : hp; |
246 |
if (answerp2 == NULL || *resplen2 < (int) sizeof (HEADER)) |
| 246 |
|
|
|
| 247 |
if (n < (int) sizeof (HEADER) && answerp2 != NULL |
| 248 |
&& *resplen2 > (int) sizeof (HEADER)) |
| 249 |
{ |
247 |
{ |
| 250 |
/* Special case of partial answer. */ |
248 |
hp2 = hp; |
| 251 |
assert (hp != hp2); |
|
|
| 252 |
hp = hp2; |
| 253 |
} |
249 |
} |
| 254 |
else if (answerp2 != NULL && *resplen2 < (int) sizeof (HEADER) |
250 |
else |
| 255 |
&& n > (int) sizeof (HEADER)) |
|
|
| 256 |
{ |
251 |
{ |
| 257 |
/* Special case of partial answer. */ |
252 |
hp2 = (HEADER *) *answerp2; |
| 258 |
assert (hp != hp2); |
253 |
if (n < (int) sizeof (HEADER)) |
| 259 |
hp2 = hp; |
254 |
{ |
|
|
255 |
hp = hp2; |
| 256 |
} |
| 260 |
} |
257 |
} |
| 261 |
|
258 |
|
|
|
259 |
/* Make sure both hp and hp2 are defined */ |
| 260 |
assert((hp != NULL) && (hp2 != NULL)); |
| 261 |
|
| 262 |
if ((hp->rcode != NOERROR || ntohs(hp->ancount) == 0) |
262 |
if ((hp->rcode != NOERROR || ntohs(hp->ancount) == 0) |
| 263 |
&& (hp2->rcode != NOERROR || ntohs(hp2->ancount) == 0)) { |
263 |
&& (hp2->rcode != NOERROR || ntohs(hp2->ancount) == 0)) { |
| 264 |
#ifdef DEBUG |
264 |
#ifdef DEBUG |