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.

Author era
Recipients era
Date 2015-06-11.13:53:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1434030821.12.0.415764944762.issue24430@psf.upfronthosting.co.za>
In-reply-to
Content
The attached archive from the Windows version of the 7z file manager (7zFM version 9.20) cannot be decrypted into memory.  The first file succeeds, but the second one fails.

The following small program is able to unzip other encrypted zip archives (tried one created by Linux 7z version 9.04 on Debian from the package p7zip-full, and one from plain zip 3.0-3 which comes from the InfoZip distribution, as well as a number of archives of unknown provenance) but fails on the attached one.

from zipfile import ZipFile
from sys import argv

container = ZipFile(argv[1])
for member in container.namelist():
    print("member %s" % member)
    try:
        extracted = container.read(member)
        print("extracted %s" % repr(extracted)[0:64])
    except RuntimeError, err:
        extracted = container.read(member, 'hello')
        container.setpassword('hello')
        print("extracted with password 'hello': %s" % repr(extracted)[0:64])

Here is the output and backtrace:

member hello/
extracted ''
member hello/goodbye.txt
Traceback (most recent call last):
  File "./nst.py", line 13, in <module>
    extracted = container.read(member, 'hello')
  File "/usr/lib/python2.6/zipfile.py", line 834, in read
    return self.open(name, "r", pwd).read()
  File "/usr/lib/python2.6/zipfile.py", line 901, in open
    raise RuntimeError("Bad password for file", name)
RuntimeError: ('Bad password for file', 'hello/goodbye.txt')

The 7z command is able to extract it just fine:

$ 7z -phello x /tmp/hello.zip

7-Zip 9.04 beta  Copyright (c) 1999-2009 Igor Pavlov  2009-05-30
p7zip Version 9.04 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,1 CPU)

Processing archive: /tmp/hello.zip

Extracting  hello
Extracting  hello/goodbye.txt
Extracting  hello/hello.txt

Everything is Ok

Folders: 1
Files: 2
Size:       15
Compressed: 560
History
Date User Action Args
2015-06-11 13:53:41erasetrecipients: + era
2015-06-11 13:53:41erasetmessageid: <1434030821.12.0.415764944762.issue24430@psf.upfronthosting.co.za>
2015-06-11 13:53:41eralinkissue24430 messages
2015-06-11 13:53:39eracreate