summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-12-11 10:55:43 +0000
committerLaurent Bercot <ska@appnovation.com>2023-12-11 10:55:43 +0000
commita0c5527de41a7274ecd789db30dd1e1368451c4a (patch)
treeb7d112380c67d0f2c1fe18dd1f8792d31084dee8
parente649847e631a6222b01ce229c29b800e8a8a0b41 (diff)
downloadshibari-a0c5527de41a7274ecd789db30dd1e1368451c4a.tar.xz
Fix easy bugs
Signed-off-by: Laurent Bercot <ska@appnovation.com>
-rw-r--r--src/common/shibari_log_query.c2
-rw-r--r--src/common/shibari_log_queryplus.c2
-rw-r--r--src/common/shibari_util_qtype_str.c4
-rw-r--r--src/server/shibari-server-tcp.c23
4 files changed, 16 insertions, 15 deletions
diff --git a/src/common/shibari_log_query.c b/src/common/shibari_log_query.c
index b04ee27..6058e12 100644
--- a/src/common/shibari_log_query.c
+++ b/src/common/shibari_log_query.c
@@ -13,6 +13,6 @@ void shibari_log_query (uint32_t v, s6dns_domain_t const *q, uint16_t qtype)
s6dns_domain_t qe ;
if (v < 2) return ;
qe = *q ;
- if (!s6dns_domain_encode(&qe) || !s6dns_domain_tostring(qs, 256, &qe)) return ;
+ if (!s6dns_domain_decode(&qe) || !s6dns_domain_tostring(qs, 256, &qe)) return ;
strerr_warni4x("query ", shibari_util_qtype_str(qtype), " ", qs) ;
}
diff --git a/src/common/shibari_log_queryplus.c b/src/common/shibari_log_queryplus.c
index 7e7fecc..b372526 100644
--- a/src/common/shibari_log_queryplus.c
+++ b/src/common/shibari_log_queryplus.c
@@ -17,7 +17,7 @@ void shibari_log_queryplus (uint32_t v, s6dns_domain_t const *q, uint16_t qtype,
s6dns_domain_t qe ;
if (v < 2) return ;
qe = *q ;
- if (!s6dns_domain_encode(&qe) || !s6dns_domain_tostring(qs, 256, &qe)) return ;
+ if (!s6dns_domain_decode(&qe) || !s6dns_domain_tostring(qs, 256, &qe)) return ;
fmti[ip46_fmt(fmti, ip)] = 0 ;
fmtp[uint16_fmt(fmtp, port)] = 0 ;
strerr_warni8x("query ", shibari_util_qtype_str(qtype), " ", qs, " ip ", fmti, " port ", fmtp) ;
diff --git a/src/common/shibari_util_qtype_str.c b/src/common/shibari_util_qtype_str.c
index 97b701d..cbbaa74 100644
--- a/src/common/shibari_util_qtype_str.c
+++ b/src/common/shibari_util_qtype_str.c
@@ -13,7 +13,7 @@ static char const *const qtype_table[262] =
"MF",
"CNAME",
"SOA",
- "MB"
+ "MB",
"MG",
"MR",
"NULL",
@@ -116,7 +116,6 @@ static char const *const qtype_table[262] =
"LP",
"EUI48",
"EUI64",
-
"unassigned",
"unassigned",
"unassigned",
@@ -256,7 +255,6 @@ static char const *const qtype_table[262] =
"unassigned",
"unassigned",
"unassigned",
-
"TKEY",
"TSIG",
"IXFR",
diff --git a/src/server/shibari-server-tcp.c b/src/server/shibari-server-tcp.c
index e646a44..ea93978 100644
--- a/src/server/shibari-server-tcp.c
+++ b/src/server/shibari-server-tcp.c
@@ -10,6 +10,7 @@
#include <skalibs/uint16.h>
#include <skalibs/uint32.h>
#include <skalibs/types.h>
+#include <skalibs/bytestr.h>
#include <skalibs/strerr.h>
#include <skalibs/buffer.h>
#include <skalibs/sgetopt.h>
@@ -74,27 +75,29 @@ static void add (shibari_packet *pkt, shibari_tdb_entry const *entry, int prefix
}
}
+#define SEPS "/,; \t\n"
+
static inline int axfr (char const *axfrok, char const *loc, cdb const *tdb, s6dns_message_header_t const *qhdr, s6dns_domain_t const *zone, shibari_packet *pkt, tain const *deadline, tain const *wstamp)
{
shibari_tdb_entry soa ;
shibari_tdb_entry cur ;
uint32_t pos = CDB_TRAVERSE_INIT() ;
- if (!axfrok) return 5 ;
- if (axfrok[0] != '*')
+ if (axfrok && axfrok[0] != '*')
{
s6dns_domain_t decoded = *zone ;
unsigned int zonelen ;
size_t len = strlen(axfrok) + 1 ;
- char buf[256] ;
+ char zbuf[256] ;
if (!s6dns_domain_decode(&decoded)) return 1 ;
- zonelen = s6dns_domain_tostring(buf, 256, &decoded) ;
- while (len >= zonelen)
+ zonelen = s6dns_domain_tostring(zbuf, 256, &decoded) ;
+ while (len)
{
- if (!strncmp(buf, axfrok, zonelen) && (!axfrok[zonelen] || strchr("/,; \t\n", axfrok[zonelen]))) break ;
- axfrok += zonelen + 1 ;
- len -= zonelen + 1 ;
+ size_t seppos = byte_in(axfrok, len, SEPS, sizeof(SEPS)) ;
+ if (!memcmp(zbuf, axfrok, seppos) && (seppos == zonelen || seppos + 1 == zonelen)) break ;
+ axfrok += seppos + 1 ;
+ len -= seppos + 1 ;
}
- if (len < zonelen) return 5 ;
+ if (!len) return 5 ;
}
{
@@ -193,7 +196,7 @@ int main (int argc, char const *const *argv)
if (w == 1) strerr_dief1x(1, "invalid request") ;
if (!w)
{
- if (errno != EPIPE && errno != ETIMEDOUT)
+ if (errno && errno != EPIPE && errno != ETIMEDOUT)
strerr_diefu1sys(111, "read from stdin") ;
else break ;
}