From 36456071ea34546d98d3b66a696cd4c4c4643de5 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 8 Sep 2015 16:01:25 +0200 Subject: [PATCH 16/16] BUG/MINOR: tools: make str2sa_range() report unresolvable addresses 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. (cherry picked from commit 9f69f46d1f1b1d116c00b4b0483c519747f977b7) --- src/standard.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/standard.c b/src/standard.c index f57724c..9299882 100644 --- a/src/standard.c +++ b/src/standard.c @@ -709,6 +709,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) { -- 2.4.6