diff options
author | Daniel Stenberg <daniel@haxx.se> | 2018-08-24 10:01:42 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2018-08-25 23:38:08 +0200 |
commit | f16bed0c45dc63864fe2097b7df939276d96d62b (patch) | |
tree | c6f400668911ee3fd8a68a2291f3de1a70d88c5c | |
parent | 2345388728cf7b788bca20dfc320346c87a355df (diff) | |
download | curl-f16bed0c45dc63864fe2097b7df939276d96d62b.tar.gz |
curl: fix time-of-check, time-of-use race in dir creation
Patch-by: Jay Satiro
Detected by Coverity
Fixes #2739
Closes #2912
-rw-r--r-- | src/tool_dirhie.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/tool_dirhie.c b/src/tool_dirhie.c index a01f9dc5f..36c06941c 100644 --- a/src/tool_dirhie.c +++ b/src/tool_dirhie.c @@ -139,12 +139,10 @@ CURLcode create_dir_hierarchy(const char *outfile, FILE *errors) else snprintf(dirbuildup, outlen, "%s%s", DIR_CHAR, tempdir); } - if(access(dirbuildup, F_OK) == -1) { - if(-1 == mkdir(dirbuildup, (mode_t)0000750)) { - show_dir_errno(errors, dirbuildup); - result = CURLE_WRITE_ERROR; - break; /* get out of loop */ - } + if((-1 == mkdir(dirbuildup, (mode_t)0000750)) && (errno != EEXIST)) { + show_dir_errno(errors, dirbuildup); + result = CURLE_WRITE_ERROR; + break; /* get out of loop */ } } tempdir = tempdir2; |