mirror of
https://github.com/git/git.git
synced 2026-01-09 01:34:00 +00:00
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()
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
#include "../git-compat-util.h"
|
||||
|
||||
char *gitmkdtemp(char *template)
|
||||
{
|
||||
if (!*mktemp(template) || mkdir(template, 0700))
|
||||
return NULL;
|
||||
return template;
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user