From 81725b867c20a688c3877421383bfe1ba9348a09 Mon Sep 17 00:00:00 2001 From: Lukas Tribus Date: Thu, 27 Feb 2020 15:47:24 +0100 Subject: [PATCH] BUG/MINOR: dns: ignore trailing dot As per issue #435 a hostname with a trailing dot confuses our DNS code, as for a zero length DNS label we emit a null-byte. This change makes us ignore the zero length label instead. Must be backported to 1.8. --- src/dns.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/dns.c b/src/dns.c index 86147a417..bbc4f4ac1 100644 --- a/src/dns.c +++ b/src/dns.c @@ -1450,6 +1450,12 @@ int dns_str_to_dn_label(const char *str, int str_len, char *dn, int dn_len) if (i == offset) return -1; + /* ignore trailing dot */ + if (i + 2 == str_len) { + i++; + break; + } + dn[offset] = (i - offset); offset = i+1; continue;