Skip to content

ban mktemp(3)

René Scharfe git 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest5 patches 1 replyIn review
  2. v14 patches 7 repliesSuperseded

Changes in v2 from the cover letter

- add comment regarding return values of git_mkdstemps_mode()
- add patch to drop trivialized gitmkdtemp()

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5wrapper: add git_mkdtemp()wrapper.c wrapper.h+21 -20 replies
2/5compat: use git_mkdtemp()compat/mkdtemp.c+1 -30 replies
3/5compat: remove mingw_mktemp()compat/mingw-posix.h compat/mingw.c+0 -150 replies
4/5banned.h: ban mktemp(3)banned.h+3 -00 replies
5/5compat: remove gitmkdtemp()Makefile compat/mkdtemp.c compat/posix.h +2 more+2 -140 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/5] ban mktemp(3)

mktemp(3) is insecure and POSIX.1-2008 no longer specifies it. Stop using it.

Changes since v1:
- add comment regarding return values of git_mkdstemps_mode()
- add patch to drop trivialized gitmkdtemp()

wrapper: add git_mkdtemp()
compat: use git_mkdtemp()
compat: remove mingw_mktemp()
banned.h: ban mktemp(3)
compat: remove gitmkdtemp()

 Makefile                            |  1 -
 banned.h                            |  3 +++
 compat/mingw-posix.h                |  3 ---
 compat/mingw.c                      | 12 ------------
 compat/mkdtemp.c                    |  8 --------
 compat/posix.h                      |  3 +--
 contrib/buildsystems/CMakeLists.txt |  4 ----
 meson.build                         |  2 +-
 wrapper.c                           | 21 +++++++++++++++++++--
 wrapper.h                           |  2 ++
 10 files changed, 26 insertions(+), 33 deletions(-)
 delete mode 100644 compat/mkdtemp.c

Range-diff against v1:
1: 830e6375aa ! 1: 413131caf6 wrapper: add git_mkdtemp()
@@ wrapper.c: int xmkstemp(char *filename_template)
#define TMP_MAX 16384

-int git_mkstemps_mode(char *pattern, int suffix_len, int mode)
++/*
++ * Returns -1 on error, 0 if it created a directory, or an open file ++ * descriptor to the created regular file.
++ */
+static int git_mkdstemps_mode(char *pattern, int suffix_len, int mode, bool dir)
{
static const char letters[] =

2:  889903eaa2 = 2:  f8850b2a92 compat: use git_mkdtemp()
3:  255b97254f = 3:  6986b4b6bf compat: remove mingw_mktemp()
4:  8300d2e224 = 4:  f34252f411 banned.h: ban mktemp(3)
-:  ---------- > 5:  d106855a23 compat: remove gitmkdtemp()
Signature · 1 line
2.52.0