BUG/MINOR: config: Stopped parsing upon unmatched environment variables
When an environment variable could not be matched by getenv(), the
current character to be parsed by parse_line() from <in> variable
is the trailing double quotes. If nothing is done in such a case,
this character is skipped by parse_line(), then the following spaces
are parsed as an empty argument.
To fix this, skip the double quotes character and the following spaces
to make <in> variable point to the next argument to be parsed.
Thank you to @sigint2 for having reported this issue in GH #2367.
Must be backported as far as 2.4.
(cherry picked from commit ff8db5a85d60b21a711f8707791119adbbcffadc)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 51fad64a3edb973370bf078df7e5fbe8862a58a2)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 2517c2e99413b8d057cabc9dc60384332f5e7b92)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 272ff1e4f0283eb1c1aa7acd70d6bfcea0db8d84)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/tools.c b/src/tools.c
index bec0a73..9c307be 100644
--- a/src/tools.c
+++ b/src/tools.c
@@ -5586,6 +5586,21 @@
}
}
}
+ else {
+ /* An unmatched environment variable was parsed.
+ * Let's skip the trailing double-quote character
+ * and spaces.
+ */
+ if (likely(*var_name != '.') && *in == '"') {
+ in++;
+ while (isspace((unsigned char)*in))
+ in++;
+ if (dquote) {
+ dquote = 0;
+ quote = NULL;
+ }
+ }
+ }
word_expand = NULL;
}
else {