[New-bugs-announce] [issue26319] Check recData size before unpack in zipfile

j w report at bugs.python.org
Tue Feb 9 05:37:56 EST 2016

New submission from j w:

Encountered on version: 2.7.3
Exception message: "error: unpack requires a string argument of length 22"

Stack trace:
  elif zipfile.is_zipfile(_file):>
File "/usr/lib/python2.7/zipfile.py", line 152, in is_zipfile>
  result = _check_zipfile(fp)>
File "/usr/lib/python2.7/zipfile.py", line 135, in _check_zipfile>
  if _EndRecData(fp):>
File "/usr/lib/python2.7/zipfile.py", line 238, in _EndRecData>
  endrec = list(struct.unpack(structEndArchive, recData))>

Check the size of recData before unpacking.
 237: recData = data[start:start+sizeEndCentDir]
 238: endrec = list(struct.unpack(structEndArchive, recData))

components: Extension Modules
messages: 259922
nosy: j w
priority: normal
severity: normal
status: open
title: Check recData size before unpack in zipfile
type: behavior
versions: Python 2.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list