diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-12-16 11:08:34 +0900 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-12-16 11:08:35 +0900 |
| commit | 91bfbf49b6566d2b412d12240336027e351a631c (patch) | |
| tree | fb6f10e6d9e0565d3d3dfe83e10652c4325239b6 /compat | |
| parent | 72154ce4147e971b59e10d79648b114481703607 (diff) | |
| parent | 10bba537c4c23e713af05be700748c6a3c25bf68 (diff) | |
| download | git-91bfbf49b6566d2b412d12240336027e351a631c.tar.gz | |
Merge branch 'rs/ban-mktemp'
Rewrite the only use of "mktemp()" that is subject to TOCTOU race
and Stop using the insecure "mktemp()" function.
* rs/ban-mktemp:
compat: remove gitmkdtemp()
banned.h: ban mktemp(3)
compat: remove mingw_mktemp()
compat: use git_mkdtemp()
wrapper: add git_mkdtemp()
Diffstat (limited to 'compat')
| -rw-r--r-- | compat/mingw-posix.h | 3 | ||||
| -rw-r--r-- | compat/mingw.c | 12 | ||||
| -rw-r--r-- | compat/mkdtemp.c | 8 | ||||
| -rw-r--r-- | compat/posix.h | 3 |
4 files changed, 1 insertions, 25 deletions
diff --git a/compat/mingw-posix.h b/compat/mingw-posix.h index 631a208684..0939feff27 100644 --- a/compat/mingw-posix.h +++ b/compat/mingw-posix.h @@ -241,9 +241,6 @@ int mingw_chdir(const char *dirname); int mingw_chmod(const char *filename, int mode); #define chmod mingw_chmod -char *mingw_mktemp(char *template); -#define mktemp mingw_mktemp - char *mingw_getcwd(char *pointer, int len); #define getcwd mingw_getcwd diff --git a/compat/mingw.c b/compat/mingw.c index 90ba5cea9d..939f938fe2 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -1164,18 +1164,6 @@ unsigned int sleep (unsigned int seconds) return 0; } -char *mingw_mktemp(char *template) -{ - wchar_t wtemplate[MAX_PATH]; - if (xutftowcs_path(wtemplate, template) < 0) - return NULL; - if (!_wmktemp(wtemplate)) - return NULL; - if (xwcstoutf(template, wtemplate, strlen(template) + 1) < 0) - return NULL; - return template; -} - int mkstemp(char *template) { return git_mkstemp_mode(template, 0600); diff --git a/compat/mkdtemp.c b/compat/mkdtemp.c deleted file mode 100644 index 1136119592..0000000000 --- a/compat/mkdtemp.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "../git-compat-util.h" - -char *gitmkdtemp(char *template) -{ - if (!*mktemp(template) || mkdir(template, 0700)) - return NULL; - return template; -} diff --git a/compat/posix.h b/compat/posix.h index 067a00f33b..245386fa4a 100644 --- a/compat/posix.h +++ b/compat/posix.h @@ -329,8 +329,7 @@ int gitsetenv(const char *, const char *, int); #endif #ifdef NO_MKDTEMP -#define mkdtemp gitmkdtemp -char *gitmkdtemp(char *); +#define mkdtemp git_mkdtemp #endif #ifdef NO_UNSETENV |
