Skip to content

Commit 8217a71

Browse files
neerajsi-msftdscho
authored andcommitted
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]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 87a24a6 commit 8217a71

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compat/mingw.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,8 +1190,11 @@ char *mingw_mktemp(char *template)
11901190
int offset = 0;
11911191

11921192
/* we need to return the path, thus no long paths here! */
1193-
if (xutftowcs_path(wtemplate, template) < 0)
1193+
if (xutftowcsn(wtemplate, template, MAX_PATH, -1) < 0) {
1194+
if (errno == ERANGE)
1195+
errno = ENAMETOOLONG;
11941196
return NULL;
1197+
}
11951198

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

0 commit comments

Comments
 (0)