summaryrefslogtreecommitdiffstats
path: root/Lib/shutil.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2023-12-05 15:40:49 (GMT)
committerGitHub <noreply@github.com>2023-12-05 15:40:49 (GMT)
commit563ccded6e83bfdd8c5622663c4edb679e96e08b (patch)
tree63294ad3f972317a65bf88d58596469a7f92c971 /Lib/shutil.py
parentbc68f4a4abcfbea60bb1db1ccadb07613561931c (diff)
downloadcpython-563ccded6e83bfdd8c5622663c4edb679e96e08b.zip
cpython-563ccded6e83bfdd8c5622663c4edb679e96e08b.tar.gz
cpython-563ccded6e83bfdd8c5622663c4edb679e96e08b.tar.bz2
gh-94692: Only catch OSError in shutil.rmtree() (#112756)
Previously a symlink attack resistant version of shutil.rmtree() could ignore or pass to the error handler arbitrary exception when invalid arguments were provided.
Diffstat (limited to 'Lib/shutil.py')
-rw-r--r--Lib/shutil.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/shutil.py b/Lib/shutil.py
index 93b00d7..bdbbcbc 100644
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -768,13 +768,13 @@ def rmtree(path, ignore_errors=False, onerror=None, *, onexc=None, dir_fd=None):
# lstat()/open()/fstat() trick.
try:
orig_st = os.lstat(path, dir_fd=dir_fd)
- except Exception as err:
+ except OSError as err:
onexc(os.lstat, path, err)
return
try:
fd = os.open(path, os.O_RDONLY, dir_fd=dir_fd)
fd_closed = False
- except Exception as err:
+ except OSError as err:
onexc(os.open, path, err)
return
try: