Skip to content

Commit

Permalink
pythongh-99889: Fix directory traversal security flaw in uu.decode()
Browse files Browse the repository at this point in the history
  • Loading branch information
samcarroll42 committed May 2, 2023
1 parent d448fcb commit 087561f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Lib/uu.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ def decode(in_file, out_file=None, mode=None, quiet=False):
out_file = hdrfields[2].rstrip(b' \t\r\n\f').decode("ascii")
if os.path.exists(out_file):
raise Error('Cannot overwrite existing file: %s' % out_file)
if '../' in out_file:
raise Error('Writing to %s would result in directory traversal' % out_file)
if mode is None:
mode = int(hdrfields[1], 8)
#
Expand Down

0 comments on commit 087561f

Please sign in to comment.