]> git.ipfire.org Git - thirdparty/git.git/commitdiff
compat: use git_mkdtemp()
authorRené Scharfe <l.s.r@web.de>
Sat, 6 Dec 2025 13:27:47 +0000 (14:27 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sat, 6 Dec 2025 22:28:12 +0000 (07:28 +0900)
A file might appear at the path returned by mktemp(3) before we call
mkdir(2).  Use the more robust git_mkdtemp() instead, which retries a
number of times and doesn't need to call lstat(2).

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/mkdtemp.c

index 11361195925c674423309d40f343c88f58b7bc1e..fcdd4e01e1461360dab9ea03193ce24038fa9a0f 100644 (file)
@@ -2,7 +2,5 @@
 
 char *gitmkdtemp(char *template)
 {
-       if (!*mktemp(template) || mkdir(template, 0700))
-               return NULL;
-       return template;
+       return git_mkdtemp(template);
 }