]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: config: Stopped parsing upon unmatched environment variables
authorFrédéric Lécaille <flecaille@haproxy.com>
Thu, 30 Nov 2023 08:26:05 +0000 (09:26 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 30 Nov 2023 15:48:41 +0000 (16:48 +0100)
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.

src/tools.c

index 0b951e15c47766aa26137509da5c8a03139b6a9f..89302eb1056dfbe8c8c50cf0d02b8cefa81b187f 100644 (file)
@@ -5809,6 +5809,21 @@ uint32_t parse_line(char *in, char *out, size_t *outlen, char **args, int *nbarg
                                        }
                                }
                        }
+                       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 {