Skip to content

Commit 4517a48

Browse files
committed
futils: document mktmp's safety
1 parent 4ac5972 commit 4517a48

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/futils.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,16 @@ typedef enum {
173173
extern int git_futils_rmdir_r(const char *path, const char *base, uint32_t flags);
174174

175175
/**
176-
* Create and open a temporary file with a `_git2_` suffix.
177-
* Writes the filename into path_out.
176+
* Create and open a temporary file with a `_git2_` suffix in a
177+
* protected directory; the file created will created will honor
178+
* the current `umask`. Writes the filename into path_out.
179+
*
180+
* This function is *NOT* suitable for use in temporary directories
181+
* that are world writable. It uses `mktemp` (for portability) and
182+
* many `mktemp` implementations use weak random characters. It
183+
* should only be assumed to be suitable for atomically writing
184+
* a new file in a directory that you control.
185+
*
178186
* @return On success, an open file descriptor, else an error code < 0.
179187
*/
180188
extern int git_futils_mktmp(git_str *path_out, const char *filename, mode_t mode);

0 commit comments

Comments
 (0)