diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-12-16 13:49:37 +0100 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-12-16 13:49:37 +0100 |
commit | 3d068b2ecfd0e04d61289dce5abed60cd88b4f9f (patch) | |
tree | 52135468db5a2c56a1ce63d49785a5e4d47fbb77 /Lib/glob.py | |
parent | dec59ec5ff9f48d1fe9bf8f5ff3874ef9f0f54ad (diff) | |
download | cpython-git-3d068b2ecfd0e04d61289dce5abed60cd88b4f9f.tar.gz |
Issue #16626: Fix infinite recursion in glob.glob() on Windows when the pattern contains a wildcard in the drive or UNC path.
Patch by Serhiy Storchaka.
Diffstat (limited to 'Lib/glob.py')
-rw-r--r-- | Lib/glob.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/glob.py b/Lib/glob.py index 36d493d7a8..7279244aa9 100644 --- a/Lib/glob.py +++ b/Lib/glob.py @@ -29,7 +29,10 @@ def iglob(pathname): for name in glob1(None, basename): yield name return - if has_magic(dirname): + # `os.path.split()` returns the argument itself as a dirname if it is a + # drive or UNC path. Prevent an infinite recursion if a drive or UNC path + # contains magic characters (i.e. r'\\?\C:'). + if dirname != pathname and has_magic(dirname): dirs = iglob(dirname) else: dirs = [dirname] |