CRUX-ARM : Home

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