mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Merge pull request #3258 from swgillespie/swgillespie/toctou-mkdir
Fix a TOCTOU issue in mkdir_p
This commit is contained in:
@@ -0,0 +1 @@
|
||||
Fixed an issue where pipenv could crash when multiple pipenv processes attempted to create the same directory.
|
||||
+11
-1
@@ -832,8 +832,18 @@ def mkdir_p(newdir):
|
||||
if head and not os.path.isdir(head):
|
||||
mkdir_p(head)
|
||||
if tail:
|
||||
os.mkdir(newdir)
|
||||
# Even though we've checked that the directory doesn't exist above, it might exist
|
||||
# now if some other process has created it between now and the time we checked it.
|
||||
try:
|
||||
os.mkdir(newdir)
|
||||
except OSError as exn:
|
||||
# If we failed because the directory does exist, that's not a problem -
|
||||
# that's what we were trying to do anyway. Only re-raise the exception
|
||||
# if we failed for some other reason.
|
||||
if exn.errno != errno.EEXIST:
|
||||
raise
|
||||
|
||||
|
||||
|
||||
def is_required_version(version, specified_version):
|
||||
"""Check to see if there's a hard requirement for version
|
||||
|
||||
Reference in New Issue
Block a user