-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
access + mkdir: a time-of-check, time-of-use race condition #2739
Labels
Comments
The question is what a decent fix would be. I'm thinking:
Then, if the mkdir() fails for another reason but the path is a directory, that's still fine. |
Thanks @bagder |
yes easiest way i think is check EEXIST diff --git a/src/tool_dirhie.c b/src/tool_dirhie.c
index a01f9dc..5755823 100644
--- a/src/tool_dirhie.c
+++ b/src/tool_dirhie.c
@@ -139,12 +139,10 @@ CURLcode create_dir_hierarchy(const char *outfile, FILE *e
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; |
Right, so someone needs to make a PR out of it... |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Detected by Coverity.
The text was updated successfully, but these errors were encountered: