1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-24 17:18:48 -05:00

curl: fix time-of-check, time-of-use race in dir creation

Patch-by: Jay Satiro
Detected by Coverity
Fixes #2739
Closes #2912
This commit is contained in:
Daniel Stenberg 2018-08-24 10:01:42 +02:00
parent 2345388728
commit f16bed0c45
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -139,14 +139,12 @@ CURLcode create_dir_hierarchy(const char *outfile, FILE *errors)
else else
snprintf(dirbuildup, outlen, "%s%s", DIR_CHAR, tempdir); snprintf(dirbuildup, outlen, "%s%s", DIR_CHAR, tempdir);
} }
if(access(dirbuildup, F_OK) == -1) { if((-1 == mkdir(dirbuildup, (mode_t)0000750)) && (errno != EEXIST)) {
if(-1 == mkdir(dirbuildup, (mode_t)0000750)) {
show_dir_errno(errors, dirbuildup); show_dir_errno(errors, dirbuildup);
result = CURLE_WRITE_ERROR; result = CURLE_WRITE_ERROR;
break; /* get out of loop */ break; /* get out of loop */
} }
} }
}
tempdir = tempdir2; tempdir = tempdir2;
} }