From ef3a92a52687cff33d77dc3b1adbee85e213094b Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Wed, 13 Dec 2023 05:43:30 +0000 Subject: Null-terminate output of s6dns_domain_tostring() Signed-off-by: Laurent Bercot --- src/libs6dns/s6dns_domain_tostring.c | 2 ++ src/libs6dns/s6dns_engine.c | 6 ++++++ 2 files changed, 8 insertions(+) (limited to 'src') diff --git a/src/libs6dns/s6dns_domain_tostring.c b/src/libs6dns/s6dns_domain_tostring.c index e11715b..2c1cf01 100644 --- a/src/libs6dns/s6dns_domain_tostring.c +++ b/src/libs6dns/s6dns_domain_tostring.c @@ -11,11 +11,13 @@ unsigned int s6dns_domain_tostring (char *s, size_t max, s6dns_domain_t const *d if (d->len == 1) { s[0] = '.' ; + s[1] = 0 ; return 1 ; } else { memcpy(s, d->s + 1, d->len - 1) ; + s[d->len - 1] = 0 ; return d->len - 1 ; } } diff --git a/src/libs6dns/s6dns_engine.c b/src/libs6dns/s6dns_engine.c index 75b41cc..7f20d73 100644 --- a/src/libs6dns/s6dns_engine.c +++ b/src/libs6dns/s6dns_engine.c @@ -5,6 +5,9 @@ #include #include #include +#ifdef DEBUG +#include +#endif #include #include @@ -396,6 +399,9 @@ int s6dns_engine_init_r (s6dns_engine_t *dt, s6dns_ip46list_t const *servers, ui memcpy(dt->sa.s + 14, q, qlen) ; uint16_pack_big(dt->sa.s + 14 + qlen, qtype) ; uint16_pack_big(dt->sa.s + 16 + qlen, S6DNS_C_IN) ; +#ifdef DEBUG + if (getenv("S6DNS_FORCE_TCP")) dt->flagtcp = 1 ; else +#endif if (qlen > 496) dt->flagtcp = 1 ; else { -- cgit v1.2.3