]>
Commit | Line | Data |
---|---|---|
0f2e926c AM |
1 | https://bugs.gentoo.org/391673 |
2 | http://sourceware.org/bugzilla/show_bug.cgi?id=13013 | |
3 | ||
4 | 2011-07-21 Aurelien Jarno <aurel32@debian.org> | |
5 | ||
6 | * resolv/res_query.c(__libc_res_nquery): Assign hp and hp2 | |
7 | depending n and resplen2 to catch cases where answer | |
8 | equals answerp2. | |
9 | ||
10 | diff --git a/resolv/res_query.c b/resolv/res_query.c | |
11 | index 2f7cfaa..405fa68 100644 | |
dfe1611b PS |
12 | --- a/resolv/res_query.c |
13 | +++ b/resolv/res_query.c | |
14 | @@ -122,6 +122,7 @@ __libc_res_nquery(res_state statp, | |
15 | int *resplen2) | |
16 | { | |
17 | HEADER *hp = (HEADER *) answer; | |
18 | + HEADER *hp2; | |
19 | int n, use_malloc = 0; | |
20 | u_int oflags = statp->_flags; | |
21 | ||
22 | @@ -239,26 +240,25 @@ __libc_res_nquery(res_state statp, | |
23 | /* __libc_res_nsend might have reallocated the buffer. */ | |
24 | hp = (HEADER *) *answerp; | |
25 | ||
26 | - /* We simplify the following tests by assigning HP to HP2. It | |
27 | - is easy to verify that this is the same as ignoring all | |
28 | - tests of HP2. */ | |
29 | - HEADER *hp2 = answerp2 ? (HEADER *) *answerp2 : hp; | |
30 | - | |
31 | - if (n < (int) sizeof (HEADER) && answerp2 != NULL | |
32 | - && *resplen2 > (int) sizeof (HEADER)) | |
33 | + /* We simplify the following tests by assigning HP to HP2 or | |
34 | + vice versa. It is easy to verify that this is the same as | |
35 | + ignoring all tests of HP or HP2. */ | |
36 | + if (answerp2 == NULL || *resplen2 < (int) sizeof (HEADER)) | |
37 | { | |
38 | - /* Special case of partial answer. */ | |
39 | - assert (hp != hp2); | |
40 | - hp = hp2; | |
41 | + hp2 = hp; | |
42 | } | |
43 | - else if (answerp2 != NULL && *resplen2 < (int) sizeof (HEADER) | |
44 | - && n > (int) sizeof (HEADER)) | |
45 | + else | |
46 | { | |
47 | - /* Special case of partial answer. */ | |
48 | - assert (hp != hp2); | |
49 | - hp2 = hp; | |
50 | + hp2 = (HEADER *) *answerp2; | |
51 | + if (n < (int) sizeof (HEADER)) | |
52 | + { | |
53 | + hp = hp2; | |
54 | + } | |
55 | } | |
56 | ||
57 | + /* Make sure both hp and hp2 are defined */ | |
58 | + assert((hp != NULL) && (hp2 != NULL)); | |
59 | + | |
60 | if ((hp->rcode != NOERROR || ntohs(hp->ancount) == 0) | |
61 | && (hp2->rcode != NOERROR || ntohs(hp2->ancount) == 0)) { | |
62 | #ifdef DEBUG |