diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-12-16 12:50:19 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-12-16 12:50:19 (GMT) |
commit | 3c331bb729b78419da455b9f8be81b566cb7a489 (patch) | |
tree | fc4d13b0097f323d7a075dd030ab4846238cff40 /Lib/glob.py | |
parent | 9ca589333844997713394b65dba9548c5887e750 (diff) | |
parent | 3d068b2ecfd0e04d61289dce5abed60cd88b4f9f (diff) | |
download | cpython-3c331bb729b78419da455b9f8be81b566cb7a489.zip cpython-3c331bb729b78419da455b9f8be81b566cb7a489.tar.gz cpython-3c331bb729b78419da455b9f8be81b566cb7a489.tar.bz2 |
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 36d493d..7279244 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] |