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.

Title: zipfile password fails validation
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.6
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gregory.p.smith Nosy List: djw, gregory.p.smith
Priority: normal Keywords:

Created on 2007-08-23 20:53 by djw, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit djw, 2007-08-30 21:17
Messages (5)
msg55210 - (view) Author: David W (djw) Date: 2007-08-23 20:53
This is in python2.5: SVN rev-56308
When testing a zipfile.Zipfile().read() with a password protected zip
file, I would continually get exceptions.  So I tracked this down to 
line 796-797: 
if ord(h[11]) != ((zinfo.CRC>>24)&255):
        raise RuntimeError, "Bad password for file %s" % name

scope related data:
bytes = `)¶G\x02ùû¬&\x1E#çÕ`
h[11] = `¯`
zinfo.CRC = `1554440319`

ord(h[11]) == 175
((zinfo.CRC>>24)&255) == 92

When I commented out the error check, the script extracted 150 JPGs with
no corruption or errors in any of the its just seems like an
issue with the error check.
msg55462 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2007-08-30 04:51
can you provide a test zip file demonstrating the problem?
msg55514 - (view) Author: David W (djw) Date: 2007-08-30 21:17
PW: 13*CrC!x

Verified again that this causes the false exception.  Waiting on the
data vendor to give me more info about the file and what is used to
create it.
msg60250 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2008-01-19 23:51
this failure also occurs on simple zip files created using infozip's zip
with -e to "encrypt" the contents.  debugging...
msg60252 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2008-01-20 01:26
Fixed in r60121 (2.6).  zip file decryption "check" bytes were more
complicated than the existing code supported.  Algorithm updated.
Date User Action Args
2022-04-11 14:56:26adminsetgithub: 45344
2008-01-20 01:26:10gregory.p.smithsetstatus: open -> closed
resolution: fixed
messages: + msg60252
versions: + Python 2.6, - Python 2.5
2008-01-19 23:51:07gregory.p.smithsetmessages: + msg60250
2007-09-17 06:38:24jafosetpriority: normal
2007-08-30 21:17:24djwsetfiles: +
messages: + msg55514
2007-08-30 04:51:23gregory.p.smithsetassignee: gregory.p.smith
type: crash -> behavior
messages: + msg55462
nosy: + gregory.p.smith
2007-08-23 20:53:16djwcreate