[PATCH v2 2/5] compat: use git_mkdtemp()
- From
René Scharfe <l.s.r@web.de>
- Date
- Dec 6, 2025, 13:27 UTC
- Message-ID
- <c8b15174-314e-4f10-94b0-e46f96bc75a4@web.de>
- In-Reply-To
- <64e62623-b911-4ddd-a481-05191853c0a6@web.de>
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> --- compat/mkdtemp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/compat/mkdtemp.c b/compat/mkdtemp.c index 1136119592..fcdd4e01e1 100644 --- a/compat/mkdtemp.c +++ b/compat/mkdtemp.c @@ -2,7 +2,5 @@ char *gitmkdtemp(char *template) { - if (!*mktemp(template) || mkdir(template, 0700)) - return NULL; - return template; + return git_mkdtemp(template); }
-- 2.52.0