Skip to content

Commit ae25974

Browse files
rscharfegitster
authored andcommitted
mingw: avoid mktemp() in mkstemp() implementation
The implementation of mkstemp() for MinGW uses mktemp() and open() without the flag O_EXCL, which is racy. It's not a security problem for now because all of its callers only create files within the repository (incl. worktrees). Replace it with a call to our more secure internal function, git_mkstemp_mode(), to prevent possible future issues. Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 359da65 commit ae25974

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

compat/mingw.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,10 +1044,7 @@ char *mingw_mktemp(char *template)
10441044

10451045
int mkstemp(char *template)
10461046
{
1047-
char *filename = mktemp(template);
1048-
if (filename == NULL)
1049-
return -1;
1050-
return open(filename, O_RDWR | O_CREAT, 0600);
1047+
return git_mkstemp_mode(template, 0600);
10511048
}
10521049

10531050
int gettimeofday(struct timeval *tv, void *tz)

0 commit comments

Comments
 (0)