Commit Diff
Diff:
7fb3593ebe69d6485bdbc43d9eccbf494d47951d
b72a627a761724fcdf27c228a353476a507b38aa
Commit:
b72a627a761724fcdf27c228a353476a507b38aa
Tree:
ebf29eff5653f000df9d2c6ac44cfe6d9d6aea91
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Thu Jul 16 07:13:13 2020 UTC
Message:
the last commit was riddled with bugs. Make sure that the database internally is always lowercase for dnsnames. This fixes a lot.
blob - b6ce1dc4ddcc24c6a733def7f708e405d80e152f
blob + 31f313534784b26b1add500ac1a8f36622c310b4
--- cache.c
+++ cache.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: cache.c,v 1.6 2020/07/15 20:27:15 pjp Exp $
+ * $Id: cache.c,v 1.7 2020/07/16 07:13:13 pjp Exp $
*/
#include <sys/types.h>
@@ -89,6 +89,7 @@ extern void pack32(char *, u_int32_t);
extern void unpack(char *, char *, int);
extern uint16_t unpack16(char *);
extern uint32_t unpack32(char *);
+extern void lower_dnsname(char *, int);
extern int debug, verbose;
@@ -187,6 +188,8 @@ transmit_rr(struct scache *scache, void *rr, int rrsiz
memcpy(ri.rri_rr.name, scache->name, sizeof(ri.rri_rr.name));
ri.rri_rr.namelen = scache->namelen;
+
+ lower_dnsname(ri.rri_rr.name, ri.rri_rr.namelen);
ri.rri_rr.ttl = scache->dnsttl;
ri.rri_rr.rrtype = scache->rrtype;
blob - 7a25c7b7d37e0e02c4621654aa9668df5a22d0ad
blob + 25199cbcce0ac2cedfa8934682b8c494bfa242a5
--- forward.c
+++ forward.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: forward.c,v 1.28 2020/07/16 06:35:55 pjp Exp $
+ * $Id: forward.c,v 1.29 2020/07/16 07:13:13 pjp Exp $
*/
#include <sys/types.h>
@@ -628,6 +628,8 @@ drop:
memcpy(rdata, &ri->rri_rr.un, ri->rri_rr.buflen);
+ lower_dnsname(ri->rri_rr.name, ri->rri_rr.namelen);
+
if ((rbt = create_rr(db, ri->rri_rr.name,
ri->rri_rr.namelen, ri->rri_rr.rrtype,
(void *)rdata, ri->rri_rr.ttl, ri->rri_rr.buflen)) == NULL) {
@@ -804,11 +806,11 @@ forwardthis(ddDB *db, struct cfg *cfg, int so, struct
}
if (sforward->havemac)
- q = build_fake_question(savednsname, sforward->buflen,
+ q = build_fake_question(sforward->buf, sforward->buflen,
sforward->type, sforward->tsigname,
sforward->tsignamelen);
else
- q = build_fake_question(savednsname, sforward->buflen,
+ q = build_fake_question(sforward->buf, sforward->buflen,
sforward->type, NULL, 0);
@@ -2175,7 +2177,7 @@ randomize_dnsname(char *buf, int len)
arc4random_buf(randompad, sizeof(randompad));
q = &buf[0];
- for (p = q, offset = 0; *p != 0; p = (p + *p + 1), offset += (*p + 1)) {
+ for (p = q, offset = 0; *p != 0; offset += (*p + 1), p += (*p + 1)) {
if (offset > DNS_MAXNAME)
return;
@@ -2198,7 +2200,7 @@ lower_dnsname(char *buf, int len)
char ch;
q = &buf[0];
- for (p = q, offset = 0; *p != 0; p = (p + *p + 1), offset += (*p + 1)) {
+ for (p = q, offset = 0; *p != 0; offset += (*p + 1), p += (*p + 1)) {
if (offset > DNS_MAXNAME)
return;
repomaster@centroid.eu