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: zipfile library will raise uncaught oserror when reading length incorrect zip file
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.10
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ultimalium
Priority: normal Keywords:

Created on 2022-03-05 17:37 by ultimalium, last changed 2022-04-11 14:59 by admin.

Files
File name Uploaded Description Edit
damaged.zip ultimalium, 2022-03-05 17:37 use notepad to open and deleted some contents of the zip file
Messages (1)
msg414590 - (view) Author: Vertu Joe (ultimalium) Date: 2022-03-05 17:37
I intentionally made some corrupted zip archive files for testing.
If some contents were removed from the archive instead of changing the bits. when trying to read such files, the zipfile will raise an uncaught  OSError, instead of a badzipfile error as expected.

os is windows 10 x64 not sure if this also happens on the UNIX system or it's intended to be happen.

code:

import zipfile
with zipfile.ZipFile(r'damaged.zip') as dmg:
    dmg.testzip()

result:
OSError
[Errno 22] Invalid argument
  File "test.py", line 20, in <module>
    file = dmg.testzip()
History
Date User Action Args
2022-04-11 14:59:57adminsetgithub: 91087
2022-03-05 17:37:33ultimaliumcreate