]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mux-h1: Properly resolve file path for 'h1-case-adjust-file'
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 15 Jun 2026 05:29:23 +0000 (07:29 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 15 Jun 2026 06:55:56 +0000 (08:55 +0200)
The file specified by 'h1-case-adjust-file' directive is only loaded during
post-parsing. However when a relative path is used, the corresponding
absoulte path was not resolve during parsing. So the file could be loaded
relatively from the wrong location leading to a configuration error. It may
happen if several configuration files are used or if several
"default-config" are used. The last "default" location was always used.

To fix the issue, the absolute path of the file is now resolved when the
directive is parsed.

This patch should fix the issue #3415. It must be backported to all
versions.

src/mux_h1.c

index 55625014499c2cb2c8ac008812ec61a87968f042..41aa3c984240ae017232f5eb10c3e3ef618d001a 100644 (file)
@@ -5986,7 +5986,24 @@ static int cfg_parse_h1_headers_case_adjust_file(char **args, int section_type,
                return -1;
        }
        free(hdrs_map.name);
-       hdrs_map.name = strdup(args[1]);
+       if (args[1][0] != '/') {
+               char *curpath;
+               char *fullpath = NULL;
+
+               /* filename is provided using relative path, store the absolute path
+                * to take current chdir into account for other threads file load
+                * which occur later
+                */
+               curpath = getcwd(trash.area, trash.size);
+               if (!curpath) {
+                       memprintf(err, "failed to retrieve cur path");
+                       return -1;
+               }
+               hdrs_map.name = memprintf(&fullpath, "%s/%s", curpath, args[1]);
+       }
+       else
+               hdrs_map.name = strdup(args[1]);
+
        if  (!hdrs_map.name) {
                memprintf(err, "'%s %s' : out of memory", args[0], args[1]);
                return -1;