diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2024-04-26 16:02:47 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2024-04-26 16:02:47 +0000 |
commit | f67f36978ca9a9f8b1a6065db7d26763c1cc456c (patch) | |
tree | d36e6c0c249c96672d6264f8ddf14b498b6c9e35 /src/server/shibari_packet_tdb_answer_query.c | |
parent | e9a0ed1fde6df9cee8ab093bce1624d89eb47ac2 (diff) | |
download | shibari-f67f36978ca9a9f8b1a6065db7d26763c1cc456c.tar.xz |
Support dns-0x20 BULLSHIT
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/server/shibari_packet_tdb_answer_query.c')
-rw-r--r-- | src/server/shibari_packet_tdb_answer_query.c | 15 |
1 files changed, 10 insertions, 5 deletions
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 ; } |