Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
6464d5ff
Kaydet (Commit)
6464d5ff
authored
Eyl 12, 2010
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #9837: The read() method of ZipExtFile objects (as returned by
ZipFile.open()) could return more bytes than requested.
üst
0b9489d2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
6 deletions
+32
-6
test_zipfile.py
Lib/test/test_zipfile.py
+20
-0
zipfile.py
Lib/zipfile.py
+9
-6
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_zipfile.py
Dosyayı görüntüle @
6464d5ff
...
...
@@ -939,6 +939,26 @@ class OtherTests(unittest.TestCase):
def
test_read_with_bad_crc_deflated
(
self
):
self
.
check_read_with_bad_crc
(
zipfile
.
ZIP_DEFLATED
)
def
check_read_return_size
(
self
,
compression
):
# Issue #9837: ZipExtFile.read() shouldn't return more bytes
# than requested.
for
test_size
in
(
1
,
4095
,
4096
,
4097
,
16384
):
file_size
=
test_size
+
1
junk
=
b
''
.
join
(
struct
.
pack
(
'B'
,
randint
(
0
,
255
))
for
x
in
range
(
file_size
))
with
zipfile
.
ZipFile
(
io
.
BytesIO
(),
"w"
,
compression
)
as
zipf
:
zipf
.
writestr
(
'foo'
,
junk
)
with
zipf
.
open
(
'foo'
,
'r'
)
as
fp
:
buf
=
fp
.
read
(
test_size
)
self
.
assertEqual
(
len
(
buf
),
test_size
)
def
test_read_return_size_stored
(
self
):
self
.
check_read_return_size
(
zipfile
.
ZIP_STORED
)
@skipUnless
(
zlib
,
"requires zlib"
)
def
test_read_return_size_deflated
(
self
):
self
.
check_read_return_size
(
zipfile
.
ZIP_DEFLATED
)
def
tearDown
(
self
):
unlink
(
TESTFN
)
unlink
(
TESTFN2
)
...
...
Lib/zipfile.py
Dosyayı görüntüle @
6464d5ff
...
...
@@ -564,17 +564,20 @@ class ZipExtFile(io.BufferedIOBase):
"""Read and return up to n bytes.
If the argument is omitted, None, or negative, data is read and returned until EOF is reached..
"""
buf
=
b
''
while
n
<
0
or
n
is
None
or
n
>
len
(
buf
):
data
=
self
.
read1
(
n
)
if
n
is
None
:
n
=
-
1
while
True
:
if
n
<
0
:
data
=
self
.
read1
(
n
)
elif
n
>
len
(
buf
):
data
=
self
.
read1
(
n
-
len
(
buf
))
else
:
return
buf
if
len
(
data
)
==
0
:
return
buf
buf
+=
data
return
buf
def
_update_crc
(
self
,
newdata
,
eof
):
# Update the CRC using the given data.
if
self
.
_expected_crc
is
None
:
...
...
Misc/NEWS
Dosyayı görüntüle @
6464d5ff
...
...
@@ -32,6 +32,9 @@ Core and Builtins
Library
-------
- Issue #9837: The read() method of ZipExtFile objects (as returned by
ZipFile.open()) could return more bytes than requested.
- Issue #9826: OrderedDict.__repr__ can now handle self-referential
values: d['x'] = d.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment