[New-bugs-announce] [issue36988] zipfile: string IndexError on extract

alter-bug-tracer report at bugs.python.org
Tue May 21 06:49:55 EDT 2019


New submission from alter-bug-tracer <emanuel.vintila at abugtracer.ro>:

The following code throws an IndexError when attempting to extract a malformed archive (attached):

import zipfile
import sys

zf = zipfile.ZipFile(sys.argv[1])
for info in zf.infolist():
  zf.extract(info.filename)

Result:
Traceback (most recent call last):
  File "code.py", line 6, in <module>
    zf.extract(info.filename)
  File "/usr/lib/python3.6/zipfile.py", line 1507, in extract
    return self._extract_member(member, path, pwd)
  File "/usr/lib/python3.6/zipfile.py", line 1572, in _extract_member
    if member.is_dir():
  File "/usr/lib/python3.6/zipfile.py", line 531, in is_dir
    return self.filename[-1] == '/'
IndexError: string index out of range

----------
files: file0.zip
messages: 343006
nosy: alter-bug-tracer
priority: normal
severity: normal
status: open
title: zipfile: string IndexError on extract
type: behavior
versions: Python 3.6, Python 3.7, Python 3.8
Added file: https://bugs.python.org/file48345/file0.zip

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36988>
_______________________________________


More information about the New-bugs-announce mailing list