summaryrefslogtreecommitdiffstats
path: root/Lib/SimpleHTTPServer.py
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2016-04-18 03:45:18 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2016-04-18 03:45:18 (GMT)
commit0cf2cf2b7d726d12a6046441e4067d32c7dd4feb (patch)
treec07ed6b3fb63988a39ce96fb2ab4eda7ede9020a /Lib/SimpleHTTPServer.py
parent9a118f1dc3f23ead28f31fdc5144ad5ce01e5b7f (diff)
downloadcpython-0cf2cf2b7d726d12a6046441e4067d32c7dd4feb.zip
cpython-0cf2cf2b7d726d12a6046441e4067d32c7dd4feb.tar.gz
cpython-0cf2cf2b7d726d12a6046441e4067d32c7dd4feb.tar.bz2
Issue #26657: Fix SimpleHTTPServer Windows directory traversal vulnerability
Based on patch by Philipp Hagemeister. This fixes a regression caused by revision 6b314f5c9404.
Diffstat (limited to 'Lib/SimpleHTTPServer.py')
-rw-r--r--Lib/SimpleHTTPServer.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/SimpleHTTPServer.py b/Lib/SimpleHTTPServer.py
index 783d0ac..c140a27 100644
--- a/Lib/SimpleHTTPServer.py
+++ b/Lib/SimpleHTTPServer.py
@@ -167,9 +167,9 @@ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
words = filter(None, words)
path = os.getcwd()
for word in words:
- drive, word = os.path.splitdrive(word)
- head, word = os.path.split(word)
- if word in (os.curdir, os.pardir): continue
+ if os.path.dirname(word) or word in (os.curdir, os.pardir):
+ # Ignore components that are not a simple file/directory name
+ continue
path = os.path.join(path, word)
if trailing_slash:
path += '/'