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
ec075e64
Kaydet (Commit)
ec075e64
authored
May 14, 2011
tarafından
Gregory P. Smith
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
merge heads
üst
79aa5bf5
ccb33bf0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
14 deletions
+39
-14
test_zlib.py
Lib/test/test_zlib.py
+11
-0
NEWS
Misc/NEWS
+5
-0
zlibmodule.c
Modules/zlibmodule.c
+23
-14
No files found.
Lib/test/test_zlib.py
Dosyayı görüntüle @
ec075e64
...
@@ -523,6 +523,17 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
...
@@ -523,6 +523,17 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
decompress
=
lambda
s
:
d
.
decompress
(
s
)
+
d
.
flush
()
decompress
=
lambda
s
:
d
.
decompress
(
s
)
+
d
.
flush
()
self
.
check_big_decompress_buffer
(
size
,
decompress
)
self
.
check_big_decompress_buffer
(
size
,
decompress
)
@precisionbigmemtest
(
size
=
_4G
+
100
,
memuse
=
1
)
def
test_length_overflow
(
self
,
size
):
if
size
<
_4G
+
100
:
self
.
skipTest
(
"not enough free memory, need at least 4 GB"
)
data
=
b
'x'
*
size
try
:
self
.
assertRaises
(
OverflowError
,
zlib
.
compress
,
data
,
1
)
self
.
assertRaises
(
OverflowError
,
zlib
.
decompress
,
data
)
finally
:
data
=
None
def
genblock
(
seed
,
length
,
step
=
1024
,
generator
=
random
):
def
genblock
(
seed
,
length
,
step
=
1024
,
generator
=
random
):
"""length-byte stream of random data from a seed (in step-byte blocks)."""
"""length-byte stream of random data from a seed (in step-byte blocks)."""
...
...
Misc/NEWS
Dosyayı görüntüle @
ec075e64
...
@@ -147,6 +147,11 @@ Core and Builtins
...
@@ -147,6 +147,11 @@ Core and Builtins
Library
Library
-------
-------
- Issue #8650: Make zlib module 64-bit clean. compress(), decompress() and
their incremental counterparts now raise OverflowError if given an input
larger than 4GB, instead of silently truncating the input and returning
an incorrect result.
- Issue #12050: zlib.decompressobj().decompress() now clears the unconsumed_tail
- Issue #12050: zlib.decompressobj().decompress() now clears the unconsumed_tail
attribute when called without a max_length argument.
attribute when called without a max_length argument.
...
...
Modules/zlibmodule.c
Dosyayı görüntüle @
ec075e64
...
@@ -420,22 +420,26 @@ PyDoc_STRVAR(comp_compress__doc__,
...
@@ -420,22 +420,26 @@ PyDoc_STRVAR(comp_compress__doc__,
static
PyObject
*
static
PyObject
*
PyZlib_objcompress
(
compobject
*
self
,
PyObject
*
args
)
PyZlib_objcompress
(
compobject
*
self
,
PyObject
*
args
)
{
{
int
err
,
inplen
;
int
err
;
unsigned
int
inplen
;
Py_ssize_t
length
=
DEFAULTALLOC
;
Py_ssize_t
length
=
DEFAULTALLOC
;
PyObject
*
RetVal
;
PyObject
*
RetVal
=
NULL
;
Py_buffer
pinput
;
Py_buffer
pinput
;
Byte
*
input
;
Byte
*
input
;
unsigned
long
start_total_out
;
unsigned
long
start_total_out
;
if
(
!
PyArg_ParseTuple
(
args
,
"y*:compress"
,
&
pinput
))
if
(
!
PyArg_ParseTuple
(
args
,
"y*:compress"
,
&
pinput
))
return
NULL
;
return
NULL
;
if
(
pinput
.
len
>
UINT_MAX
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"Size does not fit in an unsigned int"
);
goto
error_outer
;
}
input
=
pinput
.
buf
;
input
=
pinput
.
buf
;
inplen
=
pinput
.
len
;
inplen
=
pinput
.
len
;
if
(
!
(
RetVal
=
PyBytes_FromStringAndSize
(
NULL
,
length
)))
{
if
(
!
(
RetVal
=
PyBytes_FromStringAndSize
(
NULL
,
length
)))
PyBuffer_Release
(
&
pinput
);
goto
error_outer
;
return
NULL
;
}
ENTER_ZLIB
(
self
);
ENTER_ZLIB
(
self
);
...
@@ -484,6 +488,7 @@ PyZlib_objcompress(compobject *self, PyObject *args)
...
@@ -484,6 +488,7 @@ PyZlib_objcompress(compobject *self, PyObject *args)
error:
error:
LEAVE_ZLIB
(
self
);
LEAVE_ZLIB
(
self
);
error_outer:
PyBuffer_Release
(
&
pinput
);
PyBuffer_Release
(
&
pinput
);
return
RetVal
;
return
RetVal
;
}
}
...
@@ -502,9 +507,10 @@ PyDoc_STRVAR(decomp_decompress__doc__,
...
@@ -502,9 +507,10 @@ PyDoc_STRVAR(decomp_decompress__doc__,
static
PyObject
*
static
PyObject
*
PyZlib_objdecompress
(
compobject
*
self
,
PyObject
*
args
)
PyZlib_objdecompress
(
compobject
*
self
,
PyObject
*
args
)
{
{
int
err
,
inplen
,
max_length
=
0
;
int
err
,
max_length
=
0
;
unsigned
int
inplen
;
Py_ssize_t
old_length
,
length
=
DEFAULTALLOC
;
Py_ssize_t
old_length
,
length
=
DEFAULTALLOC
;
PyObject
*
RetVal
;
PyObject
*
RetVal
=
NULL
;
Py_buffer
pinput
;
Py_buffer
pinput
;
Byte
*
input
;
Byte
*
input
;
unsigned
long
start_total_out
;
unsigned
long
start_total_out
;
...
@@ -512,22 +518,24 @@ PyZlib_objdecompress(compobject *self, PyObject *args)
...
@@ -512,22 +518,24 @@ PyZlib_objdecompress(compobject *self, PyObject *args)
if
(
!
PyArg_ParseTuple
(
args
,
"y*|i:decompress"
,
&
pinput
,
if
(
!
PyArg_ParseTuple
(
args
,
"y*|i:decompress"
,
&
pinput
,
&
max_length
))
&
max_length
))
return
NULL
;
return
NULL
;
if
(
pinput
.
len
>
UINT_MAX
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"Size does not fit in an unsigned int"
);
goto
error_outer
;
}
input
=
pinput
.
buf
;
input
=
pinput
.
buf
;
inplen
=
pinput
.
len
;
inplen
=
pinput
.
len
;
if
(
max_length
<
0
)
{
if
(
max_length
<
0
)
{
PyBuffer_Release
(
&
pinput
);
PyErr_SetString
(
PyExc_ValueError
,
PyErr_SetString
(
PyExc_ValueError
,
"max_length must be greater than zero"
);
"max_length must be greater than zero"
);
return
NULL
;
goto
error_outer
;
}
}
/* limit amount of data allocated to max_length */
/* limit amount of data allocated to max_length */
if
(
max_length
&&
length
>
max_length
)
if
(
max_length
&&
length
>
max_length
)
length
=
max_length
;
length
=
max_length
;
if
(
!
(
RetVal
=
PyBytes_FromStringAndSize
(
NULL
,
length
)))
{
if
(
!
(
RetVal
=
PyBytes_FromStringAndSize
(
NULL
,
length
)))
PyBuffer_Release
(
&
pinput
);
goto
error_outer
;
return
NULL
;
}
ENTER_ZLIB
(
self
);
ENTER_ZLIB
(
self
);
...
@@ -621,6 +629,7 @@ PyZlib_objdecompress(compobject *self, PyObject *args)
...
@@ -621,6 +629,7 @@ PyZlib_objdecompress(compobject *self, PyObject *args)
error:
error:
LEAVE_ZLIB
(
self
);
LEAVE_ZLIB
(
self
);
error_outer:
PyBuffer_Release
(
&
pinput
);
PyBuffer_Release
(
&
pinput
);
return
RetVal
;
return
RetVal
;
}
}
...
...
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