Message416634
One way of doing this is by making the central directory offset negative by first taking the zip file containing just an EOCD record and then listing the total size of the central directory records as positive.
```
Python 3.11.0a4+ (heads/bpo-39064:eb1935dacf, Apr 3 2022, 19:09:53) [GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import zipfile
>>> import io
>>> b = [80, 75, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
>>> b[12] = 1
>>> f = io.BytesIO(bytes(b))
>>> zipfile.ZipFile(f)
Traceback (most recent call last):
File "/run/media/sam/OS/Git/cpython/Lib/zipfile.py", line 1370, in _RealGetContents
fp.seek(self.start_dir, 0)
^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: negative seek value -1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/run/media/sam/OS/Git/cpython/Lib/zipfile.py", line 1284, in __init__
self._RealGetContents()
^^^^^^^^^^^^^^^^^^^^^^^
File "/run/media/sam/OS/Git/cpython/Lib/zipfile.py", line 1372, in _RealGetContents
raise BadZipFile("Bad offset for central directory")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
zipfile.BadZipFile: Bad offset for central directory
>>>
``` |
|
Date |
User |
Action |
Args |
2022-04-03 18:11:13 | sam_ezeh | set | recipients:
+ sam_ezeh, serhiy.storchaka, jvoisin, iritkatriel |
2022-04-03 18:11:13 | sam_ezeh | set | messageid: <1649009473.24.0.655724659911.issue39064@roundup.psfhosted.org> |
2022-04-03 18:11:13 | sam_ezeh | link | issue39064 messages |
2022-04-03 18:11:13 | sam_ezeh | create | |
|