summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/deps-lib/shibari-common2
-rw-r--r--src/common/shibari_util_canon_domain.c20
-rw-r--r--src/include/shibari/util.h3
-rw-r--r--src/server/shibari_packet_tdb_answer_query.c15
-rw-r--r--src/server/shibari_packet_tdb_axfr.c12
5 files changed, 42 insertions, 10 deletions
diff --git a/src/common/deps-lib/shibari-common b/src/common/deps-lib/shibari-common
index a5c44a4..eed0d4f 100644
--- a/src/common/deps-lib/shibari-common
+++ b/src/common/deps-lib/shibari-common
@@ -6,5 +6,7 @@ shibari_log_start.o
shibari_util_qtype_num.o
shibari_util_qtype_str.o
shibari_util_rcode_str.o
+shibari_util_canon_domain.o
shibari_util_get_prefixlen.o
+-ls6dns
-lskarnet
diff --git a/src/common/shibari_util_canon_domain.c b/src/common/shibari_util_canon_domain.c
new file mode 100644
index 0000000..ece0c9b
--- /dev/null
+++ b/src/common/shibari_util_canon_domain.c
@@ -0,0 +1,20 @@
+/* ISC license. */
+
+#include <stdint.h>
+#include <ctype.h>
+
+#include <s6-dns/s6dns-domain.h>
+
+#include <shibari/util.h>
+
+void shibari_util_canon_domain (s6dns_domain_t *canon, s6dns_domain_t const *orig)
+{
+ uint8_t i = 0 ;
+ canon->len = orig->len ;
+ while (i < orig->len)
+ {
+ uint8_t len = orig->s[i] ;
+ canon->s[i++] = len ;
+ for (; len-- ; i++) canon->s[i] = tolower(orig->s[i]) ;
+ }
+}
diff --git a/src/include/shibari/util.h b/src/include/shibari/util.h
index 82092a3..8cbaca3 100644
--- a/src/include/shibari/util.h
+++ b/src/include/shibari/util.h
@@ -5,10 +5,13 @@
#include <stdint.h>
+#include <s6-dns/s6dns-domain.h>
+
extern char const *shibari_util_qtype_str (uint16_t) ;
extern uint16_t shibari_util_qtype_num (char const *) ;
extern char const *shibari_util_rcode_str (uint16_t) ;
+extern void shibari_util_canon_domain (s6dns_domain_t *, s6dns_domain_t const *) ;
extern int shibari_util_get_prefixlen (char const *, uint16_t, char const *, uint16_t) ;
#endif
diff --git a/src/server/shibari_packet_tdb_answer_query.c b/src/server/shibari_packet_tdb_answer_query.c
index d9e9474..74b08a2 100644
--- a/src/server/shibari_packet_tdb_answer_query.c
+++ b/src/server/shibari_packet_tdb_answer_query.c
@@ -2,9 +2,12 @@
#include <skalibs/cdb.h>
+#include <s6-dns/s6dns-domain.h>
+
#include <shibari/constants.h>
#include <shibari/tdb.h>
#include <shibari/packet.h>
+#include <shibari/util.h>
static unsigned int childzone (shibari_packet *pkt, cdb const *tdb, s6dns_domain_t const *q, char const *loc, tain const *stamp, uint16_t nplen, uint16_t zplen)
{
@@ -28,6 +31,7 @@ static unsigned int childzone (shibari_packet *pkt, cdb const *tdb, s6dns_domain
unsigned int shibari_packet_tdb_answer_query (shibari_packet *pkt, cdb const *tdb, s6dns_message_header_t const *qhdr, s6dns_domain_t const *q, uint16_t qtype, char const *loc, tain const *stamp)
{
+ s6dns_domain_t ql ;
unsigned int rcode = 0 ;
uint32_t flagyxdomain = 0 ;
int nplen, zplen ;
@@ -35,8 +39,9 @@ unsigned int shibari_packet_tdb_answer_query (shibari_packet *pkt, cdb const *td
uint16_t wildpos = 0 ;
shibari_packet_begin(pkt, qhdr->id, q, qtype) ;
+ shibari_util_canon_domain(&ql, q) ;
pkt->hdr.rd = qhdr->rd ;
- zplen = shibari_tdb_find_authority(tdb, q->s, q->len, loc, stamp, &nplen) ;
+ zplen = shibari_tdb_find_authority(tdb, ql.s, ql.len, loc, stamp, &nplen) ;
switch (zplen)
{
case -2 : return 9 ;
@@ -44,7 +49,7 @@ unsigned int shibari_packet_tdb_answer_query (shibari_packet *pkt, cdb const *td
default : break ;
}
if (nplen >= 0 && nplen < zplen)
- return childzone(pkt, tdb, q, loc, stamp, nplen, zplen) ;
+ return childzone(pkt, tdb, &ql, loc, stamp, nplen, zplen) ;
pkt->hdr.aa = 1 ; /* we're in the zone, man */
@@ -54,7 +59,7 @@ unsigned int shibari_packet_tdb_answer_query (shibari_packet *pkt, cdb const *td
for (;;)
{
shibari_tdb_entry entry ;
- int r = shibari_tdb_read_entry(tdb, &state, &entry, q->s + wildpos, q->len - wildpos, qtype, !!wildpos, loc, stamp, &flagyxdomain) ;
+ int r = shibari_tdb_read_entry(tdb, &state, &entry, ql.s + wildpos, ql.len - wildpos, qtype, !!wildpos, loc, stamp, &flagyxdomain) ;
if (r == -1) return 2 ;
if (!r) break ;
if (!shibari_packet_add_rr(pkt, &entry, 0, wildpos, 2))
@@ -81,12 +86,12 @@ unsigned int shibari_packet_tdb_answer_query (shibari_packet *pkt, cdb const *td
if (!pkt->hdr.counts.an)
{
- unsigned int r = shibari_packet_assert_authority(pkt, tdb, q->s + zplen, q->len - zplen, zplen, loc, stamp) ;
+ unsigned int r = shibari_packet_assert_authority(pkt, tdb, ql.s + zplen, ql.len - zplen, zplen, loc, stamp) ;
if (r) return r ;
}
else if (gluetype)
{
- unsigned int r = shibari_packet_add_glue(pkt, tdb, q->s, q->len, gluetype, q->s + zplen, q->len - zplen, zplen, wildpos, loc, stamp) ;
+ unsigned int r = shibari_packet_add_glue(pkt, tdb, q->s, q->len, gluetype, ql.s + zplen, ql.len - zplen, zplen, wildpos, loc, stamp) ;
if (r) return r ;
}
diff --git a/src/server/shibari_packet_tdb_axfr.c b/src/server/shibari_packet_tdb_axfr.c
index 5613b67..c8ef4e7 100644
--- a/src/server/shibari_packet_tdb_axfr.c
+++ b/src/server/shibari_packet_tdb_axfr.c
@@ -34,15 +34,15 @@ int shibari_packet_tdb_axfr (buffer *b, char const *axfrok, char const *loc, cdb
{
shibari_tdb_entry soa ;
shibari_tdb_entry cur ;
+ s6dns_domain_t z = *zone ;
uint32_t pos = CDB_TRAVERSE_INIT() ;
if (axfrok && axfrok[0] != '*')
{
- s6dns_domain_t decoded = *zone ;
unsigned int zonelen ;
size_t len = strlen(axfrok) + 1 ;
char zbuf[256] ;
- if (!s6dns_domain_decode(&decoded)) return 1 ;
- zonelen = s6dns_domain_tostring(zbuf, 256, &decoded) ;
+ if (!s6dns_domain_decode(&z)) return 1 ;
+ zonelen = s6dns_domain_tostring(zbuf, 256, &z) ;
while (len)
{
size_t seppos = byte_in(axfrok, len, SEPS, sizeof(SEPS)) ;
@@ -53,9 +53,11 @@ int shibari_packet_tdb_axfr (buffer *b, char const *axfrok, char const *loc, cdb
if (!len) return 5 ;
}
+ shibari_util_canon_domain(&z, zone) ;
+
{
cdb_find_state state = CDB_FIND_STATE_ZERO ;
- int r = shibari_tdb_read_entry(tdb, &state, &soa, zone->s, zone->len, SHIBARI_T_SOA, 0, loc, wstamp, 0) ;
+ int r = shibari_tdb_read_entry(tdb, &state, &soa, z.s, z.len, SHIBARI_T_SOA, 0, loc, wstamp, 0) ;
if (r == -1) return 2 ;
if (!r) return 9 ;
}
@@ -71,7 +73,7 @@ int shibari_packet_tdb_axfr (buffer *b, char const *axfrok, char const *loc, cdb
int r = cdb_traverse_next(tdb, &cur.key, &data, &pos) ;
if (r == -1) return 2 ;
if (!r) break ;
- prefixlen = shibari_util_get_prefixlen(cur.key.s, cur.key.len, zone->s, zone->len) ;
+ prefixlen = shibari_util_get_prefixlen(cur.key.s, cur.key.len, z.s, z.len) ;
if (prefixlen == -1) continue ;
r = shibari_tdb_entry_parse(&cur, data.s, data.len, SHIBARI_T_ANY, 2, loc, wstamp) ;
if (r == -1) return 2 ;