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
69fdbf9c
Kaydet (Commit)
69fdbf9c
authored
Ock 09, 2014
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #20078: Reading malformed zipfiles no longer hangs with 100% CPU
consumption.
üst
0ae7ae1f
5ce3f10a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
0 deletions
+36
-0
test_zipfile.py
Lib/test/test_zipfile.py
+31
-0
zipfile.py
Lib/zipfile.py
+2
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_zipfile.py
Dosyayı görüntüle @
69fdbf9c
...
...
@@ -297,6 +297,36 @@ class AbstractTestsWithSourceFile:
buf
=
fp
.
read
(
test_size
)
self
.
assertEqual
(
len
(
buf
),
test_size
)
def
test_truncated_zipfile
(
self
):
fp
=
io
.
BytesIO
()
with
zipfile
.
ZipFile
(
fp
,
mode
=
'w'
)
as
zipf
:
zipf
.
writestr
(
'strfile'
,
self
.
data
,
compress_type
=
self
.
compression
)
end_offset
=
fp
.
tell
()
zipfiledata
=
fp
.
getvalue
()
fp
=
io
.
BytesIO
(
zipfiledata
)
with
zipfile
.
ZipFile
(
fp
)
as
zipf
:
with
zipf
.
open
(
'strfile'
)
as
zipopen
:
fp
.
truncate
(
end_offset
-
20
)
with
self
.
assertRaises
(
EOFError
):
zipopen
.
read
()
fp
=
io
.
BytesIO
(
zipfiledata
)
with
zipfile
.
ZipFile
(
fp
)
as
zipf
:
with
zipf
.
open
(
'strfile'
)
as
zipopen
:
fp
.
truncate
(
end_offset
-
20
)
with
self
.
assertRaises
(
EOFError
):
while
zipopen
.
read
(
100
):
pass
fp
=
io
.
BytesIO
(
zipfiledata
)
with
zipfile
.
ZipFile
(
fp
)
as
zipf
:
with
zipf
.
open
(
'strfile'
)
as
zipopen
:
fp
.
truncate
(
end_offset
-
20
)
with
self
.
assertRaises
(
EOFError
):
while
zipopen
.
read1
(
100
):
pass
def
tearDown
(
self
):
unlink
(
TESTFN
)
unlink
(
TESTFN2
)
...
...
@@ -393,6 +423,7 @@ class StoredTestsWithSourceFile(AbstractTestsWithSourceFile,
with
zipfile
.
ZipFile
(
TESTFN2
,
"w"
)
as
zipfp
:
self
.
assertRaises
(
ValueError
,
zipfp
.
write
,
TESTFN
)
@requires_zlib
class
DeflateTestsWithSourceFile
(
AbstractTestsWithSourceFile
,
unittest
.
TestCase
):
...
...
Lib/zipfile.py
Dosyayı görüntüle @
69fdbf9c
...
...
@@ -862,6 +862,8 @@ class ZipExtFile(io.BufferedIOBase):
data
=
self
.
_fileobj
.
read
(
n
)
self
.
_compress_left
-=
len
(
data
)
if
not
data
:
raise
EOFError
if
self
.
_decrypter
is
not
None
:
data
=
bytes
(
map
(
self
.
_decrypter
,
data
))
...
...
Misc/NEWS
Dosyayı görüntüle @
69fdbf9c
...
...
@@ -18,6 +18,9 @@ Core and Builtins
Library
-------
-
Issue
#
20078
:
Reading
malformed
zipfiles
no
longer
hangs
with
100
%
CPU
consumption
.
-
Issue
#
20113
:
os
.
readv
()
and
os
.
writev
()
now
raise
an
OSError
exception
on
error
instead
of
returning
-
1.
...
...
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