Commit Diff
Diff:
03242dbb48b440eddeb24e0c65bddfefaf4a693a
3b171ff400d5e91df586af65ec7a090e44454d75
Commit:
3b171ff400d5e91df586af65ec7a090e44454d75
Tree:
8f20352a59fd32d2667eecd8108ff0b203ab4a3f
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Tue Apr 30 10:21:00 2019 UTC
Message:
with habbie's help in understanding how txt records get concatenated... (section 3.3.14 of RFC 1035 keyword "One or more 's"... This commit grows the TXT records to 1024 bytes max, which should be enough to fit a DKIM record in there. tested on OpenBSD and in production on test zone.
blob - 9fa8532ef883179645c81f0b3f3044f3dd8d874d
blob + e35653fb6130770b681f0a1e662452fb5978ccf8
--- CHANGES
+++ CHANGES
@@ -6,6 +6,7 @@ Changes in RELEASE_1_4 from RELEASE_1_3
- fixed logic leading up to DNSSEC NODATA ENT replies
- FreeLogic from Russia, offered an unalignment fix affecting rrlimit
- TSIG AXFR's and other TSIG support is now workin
+- increased TXT's size from 255 to 1024 (for DKIM)
Changes in RELEASE_1_3 from RELEASE_1_2
- created a "zinclude" config, which will only allow zone files to be
blob - a5f9f96c514dc56828cdfdb827db9f54d7a36974
blob + 810e2d3714ab51df8b79f486a4e0231e8a0a9095
--- ddd-db.h
+++ ddd-db.h
@@ -27,7 +27,7 @@
*/
/*
- * $Id: ddd-db.h,v 1.17 2019/04/07 15:18:27 pjp Exp $
+ * $Id: ddd-db.h,v 1.18 2019/04/30 10:21:00 pjp Exp $
*/
#ifndef _DB_H
@@ -219,7 +219,7 @@ struct ptr {
} __attribute__((packed));
struct txt {
- char txt[DNS_MAXNAME]; /* TXT string */
+ char txt[1024]; /* TXT string */
int txtlen; /* len of TXT */
u_int32_t ttl;
} __attribute__((packed));
blob - ebcaff8f97329e61284a5b2f7339bb7e710b421f
blob + 431e443cf3bf2277d565d29ee2fa0fa47af75710
--- dddctl.c
+++ dddctl.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: dddctl.c,v 1.61 2019/04/26 08:00:18 pjp Exp $
+ * $Id: dddctl.c,v 1.62 2019/04/30 10:21:00 pjp Exp $
*/
#include "ddd-include.h"
@@ -1895,10 +1895,8 @@ sign_txt(ddDB *db, char *zonename, struct keysentry *z
p += 2;
pack32(p, htonl(((struct txt *)rrp->rdata)->ttl));
p += 4;
- pack16(p, htons(((struct txt *)rrp->rdata)->txtlen + 1));
+ pack16(p, htons(((struct txt *)rrp->rdata)->txtlen));
p += 2;
- pack8(p, ((struct txt *)rrp->rdata)->txtlen);
- p++;
pack(p, ((struct txt *)rrp->rdata)->txt, ((struct txt *)rrp->rdata)->txtlen);
p += ((struct txt *)rrp->rdata)->txtlen;
@@ -6530,6 +6528,9 @@ print_rbt(FILE *of, struct rbtree *rbt)
((struct txt *)rrp->rdata)->ttl);
for (i = 0; i < ((struct txt *)rrp->rdata)->txtlen; i++) {
+ if (i % 256 == 0)
+ continue;
+
fprintf(of, "%c", ((struct txt *)rrp->rdata)->txt[i]);
}
fprintf(of, "\"\n");
@@ -8204,6 +8205,9 @@ print_rbt_bind(FILE *of, struct rbtree *rbt)
((struct txt *)rrp->rdata)->ttl);
for (i = 0; i < ((struct txt *)rrp->rdata)->txtlen; i++) {
+ if (i % 256 == 0)
+ continue;
+
fprintf(of, "%c", ((struct txt *)rrp->rdata)->txt[i]);
}
fprintf(of, "\"\n");
blob - d49cbf56433eec507551769cfda81233fda3046d
blob + 220463a6bb946ec865da03684c545bd1d39bc9aa
--- parse.y
+++ parse.y
@@ -21,7 +21,7 @@
*/
/*
- * $Id: parse.y,v 1.66 2019/04/25 05:54:09 pjp Exp $
+ * $Id: parse.y,v 1.67 2019/04/30 10:21:00 pjp Exp $
*/
%{
@@ -2544,17 +2544,41 @@ fill_txt(char *name, char *type, int myttl, char *msg)
struct txt *txt;
int converted_namelen;
char *converted_name;
- int len, i;
+ int len, i, j, tmplen, origlen;
+ u_char *tmp;
+ int messages = 1;
for (i = 0; i < strlen(name); i++) {
name[i] = tolower((int)name[i]);
}
- if ((len = strlen(msg)) > 255) {
- dolog(LOG_ERR, "TXT record too long line %d\n", file->lineno);
- return (-1);
+ origlen = tmplen = len = strlen(msg);
+ while (tmplen > 255) {
+ messages++;
+ tmplen -= 255;
}
+ len += messages;
+
+ if (len > 1024) {
+ dolog(LOG_ERR, "fill_txt: more than 1024 characters in TXT RR\n");
+ return -1;
+ }
+
+ tmp = malloc(len);
+ if (tmp == NULL) {
+ dolog(LOG_ERR, "calloc: %s\n", strerror(errno));
+ return -1;
+ }
+
+ for (i = 0, j = 0, tmplen = origlen; tmplen > 0; tmplen -= 255) {
+ tmp[i] = ((tmplen >= 255) ? 255 : tmplen);
+ i++;
+ memcpy(&tmp[i], &msg[j], (tmplen >= 255) ? 255 : tmplen);
+ i += 255;
+ j += 255;
+ }
+
converted_name = check_rr(name, type, DNS_TYPE_TXT, &converted_namelen);
if (converted_name == NULL) {
return -1;
@@ -2565,7 +2589,7 @@ fill_txt(char *name, char *type, int myttl, char *msg)
return -1;
}
- memcpy(&txt->txt, msg, len);
+ memcpy(&txt->txt, tmp, len);
txt->txtlen = len;
txt->ttl = myttl;
@@ -2579,6 +2603,7 @@ fill_txt(char *name, char *type, int myttl, char *msg)
free (converted_name);
free (rbt);
+ free (tmp);
return (0);
blob - 7a05d60d70b927c40927f42e226444115ae40d98
blob + 5a32d131cdc6062a9d015a638543a535ca29e4ff
--- raxfr.c
+++ raxfr.c
@@ -26,7 +26,7 @@
*
*/
/*
- * $Id: raxfr.c,v 1.11 2019/02/24 07:14:02 pjp Exp $
+ * $Id: raxfr.c,v 1.12 2019/04/30 10:21:00 pjp Exp $
*/
#include "ddd-include.h"
@@ -642,21 +642,23 @@ raxfr_txt(FILE *f, u_char *p, u_char *estart, u_char *
int i;
u_char *q = p;
- BOUNDS_CHECK((p + 1), q, rdlen, end);
- len = *p;
- p++;
+ BOUNDS_CHECK(p, q, rdlen, end);
+ len = rdlen;
if (f != NULL)
fprintf(f, "\"");
- for (i = 0; i < len; i++) {
- BOUNDS_CHECK((p + 1), q, rdlen, end);
+ for (i = 0; i < rdlen; i++) {
+ if (i % 256 == 0)
+ continue;
+
if (f != NULL)
- fprintf(f, "%c", *p);
- p++;
+ fprintf(f, "%c", p[i]);
}
if (f != NULL)
fprintf(f, "\"\n");
+
+ p += i;
return (p - estart);
blob - bc8f2b0862d13d4f8511cf221ac8c846f659f51b
blob + 9af8f61944615df4ee2060536ad727873dd2e325
--- reply.c
+++ reply.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: reply.c,v 1.76 2019/04/07 15:18:27 pjp Exp $
+ * $Id: reply.c,v 1.77 2019/04/30 10:21:00 pjp Exp $
*/
#include "ddd-include.h"
@@ -2914,11 +2914,10 @@ reply_txt(struct sreply *sreply, ddDB *db)
p = (char *)&answer->rdata;
- *p = ((struct txt *)rrp->rdata)->txtlen;
- memcpy((p + 1), ((struct txt *)rrp->rdata)->txt, ((struct txt *)rrp->rdata)->txtlen);
- outlen += (((struct txt *)rrp->rdata)->txtlen + 1);
+ memcpy(p, ((struct txt *)rrp->rdata)->txt, ((struct txt *)rrp->rdata)->txtlen);
+ outlen += (((struct txt *)rrp->rdata)->txtlen);
- answer->rdlength = htons(((struct txt *)rrp->rdata)->txtlen + 1);
+ answer->rdlength = htons(((struct txt *)rrp->rdata)->txtlen);
/* Add RRSIG reply_txt */
if (dnssec && q->dnssecok && rbt->dnssec) {
@@ -5764,15 +5763,14 @@ create_anyreply(struct sreply *sreply, char *reply, in
offset += 10; /* up to rdata length */
- if (offset + ((struct txt *)rrp->rdata)->txtlen + 1 > rlen)
+ if (offset + ((struct txt *)rrp->rdata)->txtlen > rlen)
goto truncate;
p = (char *)&answer->rdata;
- *p = ((struct txt *)rrp->rdata)->txtlen;
- memcpy((p + 1), ((struct txt *)rrp->rdata)->txt, ((struct txt *)rrp->rdata)->txtlen);
- offset += (((struct txt *)rrp->rdata)->txtlen + 1);
+ memcpy(p, ((struct txt *)rrp->rdata)->txt, ((struct txt *)rrp->rdata)->txtlen);
+ offset += (((struct txt *)rrp->rdata)->txtlen);
- answer->rdlength = htons(((struct txt *)rrp->rdata)->txtlen + 1);
+ answer->rdlength = htons(((struct txt *)rrp->rdata)->txtlen);
}
if ((rrset = find_rr(rbt, DNS_TYPE_TLSA)) != 0) {
repomaster@centroid.eu