[issue9837] ZipFileExt.read() reads more data than requested

2010-09-12 Thread Black Dew

New submission from Black Dew black...@gmail.com:

ZipFileExt.read() can return more data than requested, unlike file and other 
file-like objects.

This function calls read1() in a loop, passing the original requested size even 
if part of the data was already read thus reading and returning more than the 
caller requested.

This should be fixed by requesting n-len(buf) or something similar, or at least 
properly documented.

--
components: Library (Lib)
messages: 116158
nosy: Black.Dew
priority: normal
severity: normal
status: open
title: ZipFileExt.read() reads more data than requested
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9837
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9837] ZipFileExt.read() reads more data than requested

2010-09-12 Thread R. David Murray

Changes by R. David Murray rdmur...@bitdance.com:


--
nosy: +pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9837
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9837] ZipFileExt.read() reads more data than requested

2010-09-12 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Indeed. In most cases, though, read1(n) will return exactly n bytes and the 
loop will therefore end immediately with the right buf size. Do you have a 
simple test case?

--
versions: +Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9837
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9837] ZipFileExt.read() reads more data than requested

2010-09-12 Thread Black Dew

Black Dew black...@gmail.com added the comment:

If i follow the logic in read1() correctly it will do that only for files with 
very low compression ratios (the original sample where i noticed that problem 
was actually a chunk of encrypted data inside the zip).

From the comments referring to with at most one read() system call I would 
also assume it's OS-specific.

Anyway, I've attached a small file that reproduces this behavior on my system 
(win xp 32bit). When i run it i get AssertionError: Read returned 4097 bytes 
(4096 requested)

--
Added file: http://bugs.python.org/file18860/a.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9837
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9837] ZipFileExt.read() reads more data than requested

2010-09-12 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Ok, thank you. I've fixed the issue and added a test in r84737 (3.x) and r84739 
(2.7).

--
resolution:  - fixed
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9837
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com