]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: dns: ignore trailing dot
authorLukas Tribus <lukas@ltri.eu>
Thu, 27 Feb 2020 14:47:24 +0000 (15:47 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 28 Feb 2020 09:26:29 +0000 (10:26 +0100)
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

index 86147a4170dfd259ffc004deffa5261d96630a7a..bbc4f4ac1dab0559d7948018700c99be6e250f68 100644 (file)
--- 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;