diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-12-13 05:43:30 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2023-12-13 05:43:30 +0000 |
commit | ef3a92a52687cff33d77dc3b1adbee85e213094b (patch) | |
tree | 9fe651acb5aa1394885374b8c4f77216798230ef | |
parent | b55ef39bcb4738a376cbf6e49f88bfb2ef97bf84 (diff) | |
download | s6-dns-ef3a92a52687cff33d77dc3b1adbee85e213094b.tar.xz |
Null-terminate output of s6dns_domain_tostring()
Signed-off-by: Laurent Bercot <ska@appnovation.com>
-rw-r--r-- | src/libs6dns/s6dns_domain_tostring.c | 2 | ||||
-rw-r--r-- | src/libs6dns/s6dns_engine.c | 6 |
2 files changed, 8 insertions, 0 deletions
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 <strings.h> #include <stdint.h> #include <errno.h> +#ifdef DEBUG +#include <stdlib.h> +#endif #include <skalibs/posixishard.h> #include <skalibs/uint16.h> @@ -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 { |