Skip to content

Commit e364c95

Browse files
neerajsi-msftGit for Windows Build Agent
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 f912ad5 commit e364c95

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
@@ -1260,8 +1260,11 @@ char *mingw_mktemp(char *template)
12601260
int offset = 0;
12611261

12621262
/* we need to return the path, thus no long paths here! */
1263-
if (xutftowcs_path(wtemplate, template) < 0)
1263+
if (xutftowcsn(wtemplate, template, MAX_PATH, -1) < 0) {
1264+
if (errno == ERANGE)
1265+
errno = ENAMETOOLONG;
12641266
return NULL;
1267+
}
12651268

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

0 commit comments

Comments
 (0)