Created
November 10, 2014 10:12
-
-
Save mpdude/21f358700902d55fb616 to your computer and use it in GitHub Desktop.
Patch Ubuntu netqmail-1.06 to handle DNS packets >512 byte and remove unneeded CNAME checks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- qmail-1.03/dns.c.103 Mon Aug 17 16:06:58 1998 | |
+++ qmail-1.03/dns.c Wed Aug 26 16:28:56 1998 | |
@@ -21,10 +21,12 @@ | |
static unsigned short getshort(c) unsigned char *c; | |
{ unsigned short u; u = c[0]; return (u << 8) + c[1]; } | |
-static union { HEADER hdr; unsigned char buf[PACKETSZ]; } response; | |
+static struct { unsigned char *buf; } response; | |
+static int responsebuflen = 0; | |
static int responselen; | |
static unsigned char *responseend; | |
static unsigned char *responsepos; | |
+static u_long saveresoptions; | |
static int numanswers; | |
static char name[MAXDNAME]; | |
@@ -45,18 +47,33 @@ | |
errno = 0; | |
if (!stralloc_copy(&glue,domain)) return DNS_MEM; | |
if (!stralloc_0(&glue)) return DNS_MEM; | |
- responselen = lookup(glue.s,C_IN,type,response.buf,sizeof(response)); | |
+ if (!responsebuflen) | |
+ if (response.buf = (unsigned char *)alloc(PACKETSZ+1)) | |
+ responsebuflen = PACKETSZ+1; | |
+ else return DNS_MEM; | |
+ | |
+ responselen = lookup(glue.s,C_IN,type,response.buf,responsebuflen); | |
+ if ((responselen >= responsebuflen) || | |
+ (responselen > 0 && (((HEADER *)response.buf)->tc))) | |
+ { | |
+ if (responsebuflen < 65536) | |
+ if (alloc_re(&response.buf, responsebuflen, 65536)) | |
+ responsebuflen = 65536; | |
+ else return DNS_MEM; | |
+ saveresoptions = _res.options; | |
+ _res.options |= RES_USEVC; | |
+ responselen = lookup(glue.s,C_IN,type,response.buf,responsebuflen); | |
+ _res.options = saveresoptions; | |
+ } | |
if (responselen <= 0) | |
{ | |
if (errno == ECONNREFUSED) return DNS_SOFT; | |
if (h_errno == TRY_AGAIN) return DNS_SOFT; | |
return DNS_HARD; | |
} | |
- if (responselen >= sizeof(response)) | |
- responselen = sizeof(response); | |
responseend = response.buf + responselen; | |
responsepos = response.buf + sizeof(HEADER); | |
- n = ntohs(response.hdr.qdcount); | |
+ n = ntohs(((HEADER *)response.buf)->qdcount); | |
while (n-- > 0) | |
{ | |
i = dn_expand(response.buf,responseend,responsepos,name,MAXDNAME); | |
@@ -66,7 +83,7 @@ | |
if (i < QFIXEDSZ) return DNS_SOFT; | |
responsepos += QFIXEDSZ; | |
} | |
- numanswers = ntohs(response.hdr.ancount); | |
+ numanswers = ntohs(((HEADER *)response.buf)->ancount); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- netqmail-1.06/dns.c~ 2014-11-09 21:30:43.000000000 +0100 | |
+++ netqmail-1.06/dns.c 2014-11-09 21:32:36.954314782 +0100 | |
@@ -204,32 +204,7 @@ | |
int dns_cname(sa) | |
stralloc *sa; | |
{ | |
- int r; | |
- int loop; | |
- for (loop = 0;loop < 10;++loop) | |
- { | |
- if (!sa->len) return loop; | |
- if (sa->s[sa->len - 1] == ']') return loop; | |
- if (sa->s[sa->len - 1] == '.') { --sa->len; continue; } | |
- switch(resolve(sa,T_ANY)) | |
- { | |
- case DNS_MEM: return DNS_MEM; | |
- case DNS_SOFT: return DNS_SOFT; | |
- case DNS_HARD: return loop; | |
- default: | |
- while ((r = findname(T_CNAME)) != 2) | |
- { | |
- if (r == DNS_SOFT) return DNS_SOFT; | |
- if (r == 1) | |
- { | |
- if (!stralloc_copys(sa,name)) return DNS_MEM; | |
- break; | |
- } | |
- } | |
- if (r == 2) return loop; | |
- } | |
- } | |
- return DNS_HARD; /* alias loop */ | |
+ return 0; | |
} | |
#define FMT_IAA 40 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment