1 |
--- qmail-1.03/dns.c.103 Mon Aug 17 16:06:58 1998 |
2 |
+++ qmail-1.03/dns.c Wed Aug 26 16:28:56 1998 |
3 |
@@ -21,10 +21,12 @@ |
4 |
static unsigned short getshort(c) unsigned char *c; |
5 |
{ unsigned short u; u = c[0]; return (u << 8) + c[1]; } |
6 |
|
7 |
-static union { HEADER hdr; unsigned char buf[PACKETSZ]; } response; |
8 |
+static struct { unsigned char *buf; } response; |
9 |
+static int responsebuflen = 0; |
10 |
static int responselen; |
11 |
static unsigned char *responseend; |
12 |
static unsigned char *responsepos; |
13 |
+static u_long saveresoptions; |
14 |
|
15 |
static int numanswers; |
16 |
static char name[MAXDNAME]; |
17 |
@@ -45,18 +47,33 @@ |
18 |
errno = 0; |
19 |
if (!stralloc_copy(&glue,domain)) return DNS_MEM; |
20 |
if (!stralloc_0(&glue)) return DNS_MEM; |
21 |
- responselen = lookup(glue.s,C_IN,type,response.buf,sizeof(response)); |
22 |
+ if (!responsebuflen) |
23 |
+ if (response.buf = (unsigned char *)alloc(PACKETSZ+1)) |
24 |
+ responsebuflen = PACKETSZ+1; |
25 |
+ else return DNS_MEM; |
26 |
+ |
27 |
+ responselen = lookup(glue.s,C_IN,type,response.buf,responsebuflen); |
28 |
+ if ((responselen >= responsebuflen) || |
29 |
+ (responselen > 0 && (((HEADER *)response.buf)->tc))) |
30 |
+ { |
31 |
+ if (responsebuflen < 65536) |
32 |
+ if (alloc_re(&response.buf, responsebuflen, 65536)) |
33 |
+ responsebuflen = 65536; |
34 |
+ else return DNS_MEM; |
35 |
+ saveresoptions = _res.options; |
36 |
+ _res.options |= RES_USEVC; |
37 |
+ responselen = lookup(glue.s,C_IN,type,response.buf,responsebuflen); |
38 |
+ _res.options = saveresoptions; |
39 |
+ } |
40 |
if (responselen <= 0) |
41 |
{ |
42 |
if (errno == ECONNREFUSED) return DNS_SOFT; |
43 |
if (h_errno == TRY_AGAIN) return DNS_SOFT; |
44 |
return DNS_HARD; |
45 |
} |
46 |
- if (responselen >= sizeof(response)) |
47 |
- responselen = sizeof(response); |
48 |
responseend = response.buf + responselen; |
49 |
responsepos = response.buf + sizeof(HEADER); |
50 |
- n = ntohs(response.hdr.qdcount); |
51 |
+ n = ntohs(((HEADER *)response.buf)->qdcount); |
52 |
while (n-- > 0) |
53 |
{ |
54 |
i = dn_expand(response.buf,responseend,responsepos,name,MAXDNAME); |
55 |
@@ -66,7 +83,7 @@ |
56 |
if (i < QFIXEDSZ) return DNS_SOFT; |
57 |
responsepos += QFIXEDSZ; |
58 |
} |
59 |
- numanswers = ntohs(response.hdr.ancount); |
60 |
+ numanswers = ntohs(((HEADER *)response.buf)->ancount); |
61 |
return 0; |
62 |
} |
63 |
|