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
aead53b6
Kaydet (Commit)
aead53b6
authored
Haz 02, 2017
tarafından
Johan Liu
Kaydeden (comit)
Xiang Zhang
Haz 02, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-30245: Fix possible overflow when organize struct.pack_into error message (#1682)
üst
cdb89cd7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
2 deletions
+19
-2
test_struct.py
Lib/test/test_struct.py
+10
-0
ACKS
Misc/ACKS
+1
-0
NEWS
Misc/NEWS
+3
-0
_struct.c
Modules/_struct.c
+5
-2
No files found.
Lib/test/test_struct.py
Dosyayı görüntüle @
aead53b6
...
@@ -599,6 +599,16 @@ class StructTest(unittest.TestCase):
...
@@ -599,6 +599,16 @@ class StructTest(unittest.TestCase):
'offset -11 out of range for 10-byte buffer'
):
'offset -11 out of range for 10-byte buffer'
):
struct
.
pack_into
(
'<B'
,
byte_list
,
-
11
,
123
)
struct
.
pack_into
(
'<B'
,
byte_list
,
-
11
,
123
)
def
test_boundary_error_message_with_large_offset
(
self
):
# Test overflows cause by large offset and value size (issue 30245)
regex
=
(
r'pack_into requires a buffer of at least '
+
str
(
sys
.
maxsize
+
4
)
+
r' bytes for packing 4 bytes at offset '
+
str
(
sys
.
maxsize
)
+
r' \(actual buffer size is 10\)'
)
with
self
.
assertRaisesRegex
(
struct
.
error
,
regex
):
struct
.
pack_into
(
'<I'
,
bytearray
(
10
),
sys
.
maxsize
,
1
)
def
test_issue29802
(
self
):
def
test_issue29802
(
self
):
# When the second argument of struct.unpack() was of wrong type
# When the second argument of struct.unpack() was of wrong type
# the Struct object was decrefed twice and the reference to
# the Struct object was decrefed twice and the reference to
...
...
Misc/ACKS
Dosyayı görüntüle @
aead53b6
...
@@ -921,6 +921,7 @@ Gregor Lingl
...
@@ -921,6 +921,7 @@ Gregor Lingl
Everett Lipman
Everett Lipman
Mirko Liss
Mirko Liss
Alexander Liu
Alexander Liu
Yuan Liu
Nick Lockwood
Nick Lockwood
Stephanie Lockwood
Stephanie Lockwood
Martin von Löwis
Martin von Löwis
...
...
Misc/NEWS
Dosyayı görüntüle @
aead53b6
...
@@ -345,6 +345,9 @@ Extension Modules
...
@@ -345,6 +345,9 @@ Extension Modules
Library
Library
-------
-------
- bpo-30245: Fix possible overflow when organize struct.pack_into
error message. Patch by Yuan Liu.
- bpo-30378: Fix the problem that logging.handlers.SysLogHandler cannot
- bpo-30378: Fix the problem that logging.handlers.SysLogHandler cannot
handle IPv6 addresses.
handle IPv6 addresses.
...
...
Modules/_struct.c
Dosyayı görüntüle @
aead53b6
...
@@ -1929,11 +1929,14 @@ s_pack_into(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames
...
@@ -1929,11 +1929,14 @@ s_pack_into(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames
/* Check boundaries */
/* Check boundaries */
if
((
buffer
.
len
-
offset
)
<
soself
->
s_size
)
{
if
((
buffer
.
len
-
offset
)
<
soself
->
s_size
)
{
assert
(
offset
>=
0
);
assert
(
soself
->
s_size
>=
0
);
PyErr_Format
(
StructError
,
PyErr_Format
(
StructError
,
"pack_into requires a buffer of at least %z
d
bytes for "
"pack_into requires a buffer of at least %z
u
bytes for "
"packing %zd bytes at offset %zd "
"packing %zd bytes at offset %zd "
"(actual buffer size is %zd)"
,
"(actual buffer size is %zd)"
,
soself
->
s_size
+
offset
,
(
size_t
)
soself
->
s_size
+
(
size_t
)
offset
,
soself
->
s_size
,
soself
->
s_size
,
offset
,
offset
,
buffer
.
len
);
buffer
.
len
);
...
...
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