]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: tools: make str2sa_range() report unresolvable addresses
authorWilly Tarreau <w@1wt.eu>
Tue, 8 Sep 2015 14:01:25 +0000 (16:01 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 8 Sep 2015 14:01:25 +0000 (16:01 +0200)
If an environment variable is used in an address, and is not set, it's
silently considered as ":" or "0.0.0.0:0" which is not correct as it
can hide environment issues and lead to unexpected behaviours. Let's
report this case when it happens.

This fix should be backported to 1.5.

src/standard.c

index 58cc5deb4329ebed035527bc42d3f709e3c48b59..7964b88ddb46aadd98a0319326205064a3de4a40 100644 (file)
@@ -782,6 +782,11 @@ struct sockaddr_storage *str2sa_range(const char *str, int *low, int *high, char
                goto out;
        }
 
+       if (!*str2) {
+               memprintf(err, "'%s' resolves to an empty address (environment variable missing?)\n", str);
+               goto out;
+       }
+
        memset(&ss, 0, sizeof(ss));
 
        if (strncmp(str2, "unix@", 5) == 0) {