1 Accept oversize DNS packets; CNAME errors avoidance |
1 Accept oversize DNS packets; CNAME errors avoidance |
2 |
2 |
|
3 diff -r 262ce8533627 source/dietlibc/diet-qmail/qmail-103-oversize-dns.patch |
|
4 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
5 +++ b/source/dietlibc/diet-qmail/qmail-103-oversize-dns.patch Fri May 04 20:46:20 2012 +0200 |
|
6 @@ -0,0 +1,71 @@ |
|
7 +http://www.ckdhr.com/ckd/qmail-103.patch |
|
8 + |
|
9 +Description from http://qmail.ruk.cuni.cz/top.html : |
|
10 +Christopher K. Davis has a patch to accept oversize DNS packets which works on |
|
11 +both qmail's dns.c and tcpserver's dns.c. If you don't want to patch qmail, you |
|
12 +can ameliorate the problem somewhat using djbdns, which returns only the |
|
13 +records you ask for, making for a smaller ANSWER section. |
|
14 + |
|
15 +--- qmail-1.03/dns.c.103 Mon Aug 17 16:06:58 1998 |
|
16 ++++ qmail-1.03/dns.c Wed Aug 26 16:28:56 1998 |
|
17 +@@ -21,10 +21,12 @@ |
|
18 + static unsigned short getshort(c) unsigned char *c; |
|
19 + { unsigned short u; u = c[0]; return (u << 8) + c[1]; } |
|
20 + |
|
21 +-static union { HEADER hdr; unsigned char buf[PACKETSZ]; } response; |
|
22 ++static struct { unsigned char *buf; } response; |
|
23 ++static int responsebuflen = 0; |
|
24 + static int responselen; |
|
25 + static unsigned char *responseend; |
|
26 + static unsigned char *responsepos; |
|
27 ++static u_long saveresoptions; |
|
28 + |
|
29 + static int numanswers; |
|
30 + static char name[MAXDNAME]; |
|
31 +@@ -45,18 +47,33 @@ |
|
32 + errno = 0; |
|
33 + if (!stralloc_copy(&glue,domain)) return DNS_MEM; |
|
34 + if (!stralloc_0(&glue)) return DNS_MEM; |
|
35 +- responselen = lookup(glue.s,C_IN,type,response.buf,sizeof(response)); |
|
36 ++ if (!responsebuflen) |
|
37 ++ if (response.buf = (unsigned char *)alloc(PACKETSZ+1)) |
|
38 ++ responsebuflen = PACKETSZ+1; |
|
39 ++ else return DNS_MEM; |
|
40 ++ |
|
41 ++ responselen = lookup(glue.s,C_IN,type,response.buf,responsebuflen); |
|
42 ++ if ((responselen >= responsebuflen) || |
|
43 ++ (responselen > 0 && (((HEADER *)response.buf)->tc))) |
|
44 ++ { |
|
45 ++ if (responsebuflen < 65536) |
|
46 ++ if (alloc_re(&response.buf, responsebuflen, 65536)) |
|
47 ++ responsebuflen = 65536; |
|
48 ++ else return DNS_MEM; |
|
49 ++ saveresoptions = _res.options; |
|
50 ++ _res.options |= RES_USEVC; |
|
51 ++ responselen = lookup(glue.s,C_IN,type,response.buf,responsebuflen); |
|
52 ++ _res.options = saveresoptions; |
|
53 ++ } |
|
54 + if (responselen <= 0) |
|
55 + { |
|
56 + if (errno == ECONNREFUSED) return DNS_SOFT; |
|
57 + if (h_errno == TRY_AGAIN) return DNS_SOFT; |
|
58 + return DNS_HARD; |
|
59 + } |
|
60 +- if (responselen >= sizeof(response)) |
|
61 +- responselen = sizeof(response); |
|
62 + responseend = response.buf + responselen; |
|
63 + responsepos = response.buf + sizeof(HEADER); |
|
64 +- n = ntohs(response.hdr.qdcount); |
|
65 ++ n = ntohs(((HEADER *)response.buf)->qdcount); |
|
66 + while (n-- > 0) |
|
67 + { |
|
68 + i = dn_expand(response.buf,responseend,responsepos,name,MAXDNAME); |
|
69 +@@ -66,7 +83,7 @@ |
|
70 + if (i < QFIXEDSZ) return DNS_SOFT; |
|
71 + responsepos += QFIXEDSZ; |
|
72 + } |
|
73 +- numanswers = ntohs(response.hdr.ancount); |
|
74 ++ numanswers = ntohs(((HEADER *)response.buf)->ancount); |
|
75 + return 0; |
|
76 + } |
|
77 + |