Skip to content

Commit 82a16a2

Browse files
committed
BUG/MINOR: mux-h1: Properly resolve file path for 'h1-case-adjust-file'
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.
1 parent 292b072 commit 82a16a2

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

src/mux_h1.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5986,7 +5986,24 @@ static int cfg_parse_h1_headers_case_adjust_file(char **args, int section_type,
59865986
return -1;
59875987
}
59885988
free(hdrs_map.name);
5989-
hdrs_map.name = strdup(args[1]);
5989+
if (args[1][0] != '/') {
5990+
char *curpath;
5991+
char *fullpath = NULL;
5992+
5993+
/* filename is provided using relative path, store the absolute path
5994+
* to take current chdir into account for other threads file load
5995+
* which occur later
5996+
*/
5997+
curpath = getcwd(trash.area, trash.size);
5998+
if (!curpath) {
5999+
memprintf(err, "failed to retrieve cur path");
6000+
return -1;
6001+
}
6002+
hdrs_map.name = memprintf(&fullpath, "%s/%s", curpath, args[1]);
6003+
}
6004+
else
6005+
hdrs_map.name = strdup(args[1]);
6006+
59906007
if (!hdrs_map.name) {
59916008
memprintf(err, "'%s %s' : out of memory", args[0], args[1]);
59926009
return -1;

0 commit comments

Comments
 (0)