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.
(cherry picked from commit 81725b867c20a688c3877421383bfe1ba9348a09)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit b78784583d9661972d8e72a652309ef2f724e5c8)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/dns.c b/src/dns.c
index e8801f2..282fa92 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -1205,6 +1205,12 @@
if (i == offset)
return -1;
+ /* ignore trailing dot */
+ if (i + 2 == str_len) {
+ i++;
+ break;
+ }
+
dn[offset] = (i - offset);
offset = i+1;
continue;