[issue39064] ValueError in zipfile.ZipFile

2022-04-03 Thread Sam Ezeh


Change by Sam Ezeh :


--
pull_requests: +30353
pull_request: https://github.com/python/cpython/pull/32291

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39064] ValueError in zipfile.ZipFile

2022-04-03 Thread Sam Ezeh


Sam Ezeh  added the comment:

Yes, of course.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39064] ValueError in zipfile.ZipFile

2022-04-03 Thread Irit Katriel


Irit Katriel  added the comment:

Sam, can you put that in a PR please?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39064] ValueError in zipfile.ZipFile

2022-04-03 Thread Sam Ezeh


Sam Ezeh  added the comment:

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 "", line 1, in 
  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
>>> 
```

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39064] ValueError in zipfile.ZipFile

2022-04-03 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Try to create a normal ZIP file (it can be empty), then try to set some byte to 
FF (or a pair of bytes to , or 4 consequent bytes to , until you 
get the exactly same error). Then you can just add the binary dump of that file 
in tests.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39064] ValueError in zipfile.ZipFile

2022-04-03 Thread Sam Ezeh


Change by Sam Ezeh :


--
nosy: +sam_ezeh

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39064] ValueError in zipfile.ZipFile

2022-01-24 Thread Irit Katriel


Irit Katriel  added the comment:

It's easy enough to convert the exception type (see patch), but I don't know 
how to write a unit test for this.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39064] ValueError in zipfile.ZipFile

2022-01-24 Thread Irit Katriel


Change by Irit Katriel :


--
keywords: +patch
pull_requests: +29044
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/30863

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39064] ValueError in zipfile.ZipFile

2022-01-17 Thread Irit Katriel


Change by Irit Katriel :


--
versions: +Python 3.9 -Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39064] ValueError in zipfile.ZipFile

2022-01-17 Thread jvoisin


jvoisin  added the comment:

Yes, I can reproduce it:

```
$ python3 --version
Python 3.9.9

$ python3.9 ziprepo.py 
./crash-4da08e9ababa495ac51ecad588fd61081a66b5bb6e7a0e791f44907fa274ec62 
Traceback (most recent call last):
  File "/home/jvoisin/Downloads/ziprepo.py", line 4, in 
zipfile.ZipFile(sys.argv[1])
  File "/usr/lib/python3.9/zipfile.py", line 1257, in __init__
self._RealGetContents()
  File "/usr/lib/python3.9/zipfile.py", line 1342, in _RealGetContents
fp.seek(self.start_dir, 0)
ValueError: cannot fit 'int' into an offset-sized integer
$
```

> It's unlikely that anyone will download a binary from bpo and open it. Can 
> you help us reproduce the issue without that?

The *binary* is a corrupted zip file to open with `zipfile.ZipFile()`, it can't 
be executed on its own.

--
status: pending -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39064] ValueError in zipfile.ZipFile

2022-01-16 Thread Irit Katriel


Irit Katriel  added the comment:

It's unlikely that anyone will download a binary from bpo and open it. Can you 
help us reproduce the issue without that?

First question is whether you can reproduce this on a version of python that is 
still in maintenance - 3.9 or higher?

--
nosy: +iritkatriel
status: open -> pending

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39064] ValueError in zipfile.ZipFile

2019-12-16 Thread jvoisin


New submission from jvoisin :

The attached file produces the following stacktrace when opened via 
`zipfile.ZipFile`, on Python 3.7.5rc1:

```
$ cat ziprepro.py 
import zipfile
import sys

zipfile.ZipFile(sys.argv[1])
```

```
$ python3 ziprepro.py 
crash-4da08e9ababa495ac51ecad588fd61081a66b5bb6e7a0e791f44907fa274ec62
Traceback (most recent call last):
  File "ziprepro.py", line 4, in 
zipfile.ZipFile(sys.argv[1])
  File "/usr/lib/python3.7/zipfile.py", line 1225, in __init__
self._RealGetContents()
  File "/usr/lib/python3.7/zipfile.py", line 1310, in _RealGetContents
fp.seek(self.start_dir, 0)
ValueError: cannot fit 'int' into an offset-sized integer
```

The ValueError exception isn't documented as a possible exception when using 
zipfile.ZipFile ( https://docs.python.org/3/library/tarfile.html ).

--
components: Library (Lib)
files: crash-4da08e9ababa495ac51ecad588fd61081a66b5bb6e7a0e791f44907fa274ec62
messages: 358484
nosy: jvoisin
priority: normal
severity: normal
status: open
title: ValueError in zipfile.ZipFile
type: behavior
versions: Python 3.7
Added file: 
https://bugs.python.org/file48782/crash-4da08e9ababa495ac51ecad588fd61081a66b5bb6e7a0e791f44907fa274ec62

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com