BUG/MINOR: resolvers: do not reject host names of length 255 in SRV records
authorWilly Tarreau <w@1wt.eu>
Thu, 14 Oct 2021 06:00:38 +0000 (08:00 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 3 Nov 2021 10:16:36 +0000 (11:16 +0100)
An off-by-one issue in buffer size calculation used to limit the output
of resolv_dn_label_to_str() to 254 instead of 255.

This must be backported to 2.0.

(cherry picked from commit 85c15e6bff92c2dae609d76f72c1d231d048dd74)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 2859c162c2e8499e5be77972000aca2cb2e53a67)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

src/dns.c

index 25807ca..d815368 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -838,10 +838,10 @@ srv_found:
 
                                if (!srv->hostname_dn) {
                                        const char *msg = NULL;
-                                       char hostname[DNS_MAX_NAME_SIZE];
+                                       char hostname[DNS_MAX_NAME_SIZE+1];
 
                                        if (dns_dn_label_to_str(item->target, item->data_len+1,
-                                                               hostname, DNS_MAX_NAME_SIZE) == -1) {
+                                                               hostname, sizeof(hostname)) == -1) {
                                                HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock);
                                                continue;
                                        }