diff options
author | Stefan Fritsch <sf@apache.org> | 2011-10-15 20:48:52 +0000 |
---|---|---|
committer | Stefan Fritsch <sf@apache.org> | 2011-10-15 20:48:52 +0000 |
commit | ae9fb5e0c13d2d8d49e1d777a2af3295aa053c04 (patch) | |
tree | 0a0afcd3cc10edda46c5b1de9846b3ff095087fe /file_io/os2 | |
parent | f02a3b408242146aea84df350c4b8c7e53d0ae7b (diff) | |
download | apr-ae9fb5e0c13d2d8d49e1d777a2af3295aa053c04.tar.gz |
Fix race condition that could lead to EEXIST being returned
PR: 51254
Submitted by: William Lee <william lee rainstor com>,
Wim Lewis <wiml omnigroup com>
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1183688 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io/os2')
-rw-r--r-- | file_io/os2/dir_make_recurse.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/file_io/os2/dir_make_recurse.c b/file_io/os2/dir_make_recurse.c index 1f645b7dd..602a621ae 100644 --- a/file_io/os2/dir_make_recurse.c +++ b/file_io/os2/dir_make_recurse.c @@ -67,10 +67,6 @@ apr_status_t apr_dir_make_recursive(const char *path, apr_fileperms_t perm, apr_err = apr_dir_make(path, perm, pool); /* Try to make PATH right out */ - if (APR_STATUS_IS_EEXIST(apr_err)) { /* It's OK if PATH exists */ - return APR_SUCCESS; - } - if (APR_STATUS_IS_ENOENT(apr_err)) { /* Missing an intermediate dir */ char *dir; @@ -82,5 +78,13 @@ apr_status_t apr_dir_make_recursive(const char *path, apr_fileperms_t perm, } } + /* + * It's OK if PATH exists. Timing issues can lead to the second + * apr_dir_make being called on existing dir, therefore this check + * has to come last. + */ + if (APR_STATUS_IS_EEXIST(apr_err)) + return APR_SUCCESS; + return apr_err; } |