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