This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ZipExtFile:_update_crc fails for CRC >= 0x80000000
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: arindam, nadeem.vawda, pitrou, srid
Priority: normal Keywords:

Created on 2011-01-14 09:43 by arindam, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
a.zip arindam, 2011-01-17 16:24 test zip file
Messages (8)
msg126250 - (view) Author: arindam (arindam) Date: 2011-01-14 09:43
File: zipfile.py
Function: _update_crc
statement: if eof and self._running_crc != self._expected_crc:

Due to comparison of long with int, "if eof and self._running_crc != self._expected_crc:" fails when _expected_crc is negative (0x80000000 or more). Type of _running_crc is long while _expected_crc is int.

How to reproduce: Unzip a zip file containing a file having CRC >= 0x80000000.

The issue is seen with 3.1 also.
msg126278 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-01-14 17:06
Can you provide such a file? What system are you testing on?
msg126353 - (view) Author: Nadeem Vawda (nadeem.vawda) * (Python committer) Date: 2011-01-16 00:10
I have been unable to reproduce this on either 3.2rc1 or 2.6. I used a Zip archive containing a single file with the data b"a\n" (CRC 0xDDEAA107).
msg126408 - (view) Author: arindam (arindam) Date: 2011-01-17 16:24
Attached test file a.zip. Happening with 2.7.1.3. The changes came with   /python/branches/release27-maint/Lib/zipfile.py revision 83961
msg126420 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-01-17 17:51
> Attached test file a.zip. Happening with 2.7.1.3. The changes came
> with   /python/branches/release27-maint/Lib/zipfile.py revision 83961

I tested with 2.7.x and 3.2 (both from latest SVN) and couldn't reproduce (I used testzip() and extractall()), both in 32-bit and 64-bit builds.

Can you clarify which OS you are using? Also, what is 2.7.1.3? We don't have a such version (see http://python.org/download/releases/ for official releases). If you are using a Python provided by a third-party distributor (such as ActiveState or a Linux distribution), you might want to report the bug to them, since AFAICT the bug doesn't exist on the official builds.
msg126427 - (view) Author: arindam (arindam) Date: 2011-01-17 18:44
Able to get the issue with
Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32

This is the latest version for 2.7.x

Please try with the uploaded a.zip
msg126428 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-01-17 19:18
> Able to get the issue with
> Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32

Ok, I tried with this exact version and I still can't reproduce.
Can you explain which steps exactly are necessary to exhibit this issue?
msg126432 - (view) Author: arindam (arindam) Date: 2011-01-17 19:42
Legacy code in my module was setting zipfile.structCentralDir to "<4s4B4H3l5H2L" (was added to fix some issues with older version of python) was the root cause of this issue. Sorry, should have checked before filing. Thanks for your time. Sorry once again.
History
Date User Action Args
2022-04-11 14:57:11adminsetgithub: 55112
2011-01-17 19:42:38arindamsetstatus: open -> closed

messages: + msg126432
resolution: not a bug
nosy: pitrou, nadeem.vawda, srid, arindam
2011-01-17 19:18:36pitrousetnosy: pitrou, nadeem.vawda, srid, arindam
messages: + msg126428
2011-01-17 18:44:55arindamsetnosy: pitrou, nadeem.vawda, srid, arindam
messages: + msg126427
2011-01-17 17:51:36pitrousetnosy: + srid
messages: + msg126420
2011-01-17 16:24:30arindamsetfiles: + a.zip
nosy: pitrou, nadeem.vawda, arindam
messages: + msg126408
2011-01-16 00:10:54nadeem.vawdasetnosy: + nadeem.vawda
messages: + msg126353
2011-01-14 17:06:46pitrousetnosy: + pitrou
messages: + msg126278
2011-01-14 09:43:32arindamcreate