Skip to content

Commit 435e1d2

Browse files
committed
mingw: do not call xutftowcs_path in mingw_mktemp
The `xutftowcs_path` function canonicalizes absolute paths using GetFullPathNameW. This canonicalization may change the length of the string (e.g. getting rid of \.\), which breaks callers that pass the template string in a strbuf and expect the length of the string to remain the same. In my particular case, the tmp-objdir code is passing a strbuf to mkdtemp and is breaking since the strbuf.len is no longer synchronized with strlen(strbuf.buf). Signed-off-by: Neeraj K. Singh <[email protected]>
1 parent 08a757b commit 435e1d2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compat/mingw.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -1239,8 +1239,11 @@ char *mingw_mktemp(char *template)
12391239
int offset = 0;
12401240

12411241
/* we need to return the path, thus no long paths here! */
1242-
if (xutftowcs_path(wtemplate, template) < 0)
1242+
if (xutftowcsn(wtemplate, template, MAX_PATH, -1) < 0) {
1243+
if (errno == ERANGE)
1244+
errno = ENAMETOOLONG;
12431245
return NULL;
1246+
}
12441247

12451248
if (is_dir_sep(template[0]) && !is_dir_sep(template[1]) &&
12461249
iswalpha(wtemplate[0]) && wtemplate[1] == L':') {

0 commit comments

Comments
 (0)