1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-06-09 16:26:46 +02:00

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 <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe 2022-07-15 05:58:50 +02:00 committed by Junio C Hamano
parent 359da658ae
commit ae25974de3

View File

@ -1044,10 +1044,7 @@ char *mingw_mktemp(char *template)
int mkstemp(char *template)
{
char *filename = mktemp(template);
if (filename == NULL)
return -1;
return open(filename, O_RDWR | O_CREAT, 0600);
return git_mkstemp_mode(template, 0600);
}
int gettimeofday(struct timeval *tv, void *tz)