]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: haload: allow "0" shortcut for IPv4 bind address
authorFrederic Lecaille <flecaille@haproxy.com>
Wed, 8 Jul 2026 15:34:30 +0000 (17:34 +0200)
committerFrederic Lecaille <flecaille@haproxy.com>
Wed, 8 Jul 2026 15:35:34 +0000 (17:35 +0200)
The address parser was failing when using "0" as a shortcut for INADDR_ANY.
This patch intercepts the "0" prefix and normalizes it to "0.0.0.0"
before the address is parsed.

src/haload_init.c

index f842fe053123a8a70b3af5bd1930832bd695d112..08cf051a03f719d22b95984ea2dff14715fa88bb 100644 (file)
@@ -187,7 +187,7 @@ static struct hld_url_cfg *hld_alloc_url(char *url)
        struct hld_url_cfg *purl;
        struct hld_path *p = NULL;
        struct hbuf opts_buf = HBUF_NULL;
-       char quic_addr[128];
+       char quic_addr[128], tmp_addr[16];
 
        if (strncmp(url, "http://", 7) == 0)
                addr = url + 7;
@@ -250,6 +250,11 @@ static struct hld_url_cfg *hld_alloc_url(char *url)
                }
        }
 
+       if (addr[0] == '0' && addr[1] == ':') {
+               snprintf(tmp_addr, sizeof(tmp_addr), "0.0.0.0:%s", addr + 2);
+               addr = tmp_addr;
+       }
+
        if (!is_quic) {
                addr = strdup(addr);
        }