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
b93d8637
Kaydet (Commit)
b93d8637
authored
Tem 25, 2016
tarafından
Martin Panter
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #1621: Avoid signed overflow in list and tuple operations
Patch by Xiang Zhang.
üst
32d2ce35
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
11 deletions
+28
-11
list_tests.py
Lib/test/list_tests.py
+13
-1
NEWS
Misc/NEWS
+3
-0
listobject.c
Objects/listobject.c
+10
-8
tupleobject.c
Objects/tupleobject.c
+2
-2
No files found.
Lib/test/list_tests.py
Dosyayı görüntüle @
b93d8637
...
...
@@ -266,9 +266,21 @@ class CommonTest(seq_tests.CommonTest):
self
.
assertEqual
(
a
,
list
(
"spameggs"
))
self
.
assertRaises
(
TypeError
,
a
.
extend
,
None
)
self
.
assertRaises
(
TypeError
,
a
.
extend
)
# overflow test. issue1621
class
CustomIter
:
def
__iter__
(
self
):
return
self
def
__next__
(
self
):
raise
StopIteration
def
__length_hint__
(
self
):
return
sys
.
maxsize
a
=
self
.
type2test
([
1
,
2
,
3
,
4
])
a
.
extend
(
CustomIter
())
self
.
assertEqual
(
a
,
[
1
,
2
,
3
,
4
])
def
test_insert
(
self
):
a
=
self
.
type2test
([
0
,
1
,
2
])
a
.
insert
(
0
,
-
2
)
...
...
Misc/NEWS
Dosyayı görüntüle @
b93d8637
...
...
@@ -16,6 +16,9 @@ Core and Builtins
- Issue #27581: Don'
t
rely
on
wrapping
for
overflow
check
in
PySequence_Tuple
().
Patch
by
Xiang
Zhang
.
-
Issue
#
1621
:
Avoid
signed
integer
overflow
in
list
and
tuple
operations
.
Patch
by
Xiang
Zhang
.
-
Issue
#
27419
:
Standard
__import__
()
no
longer
look
up
"__import__"
in
globals
or
builtins
for
importing
submodules
or
"from import"
.
Fixed
a
crash
if
raise
a
warning
about
unabling
to
resolve
package
from
__spec__
or
...
...
Objects/listobject.c
Dosyayı görüntüle @
b93d8637
...
...
@@ -488,9 +488,9 @@ list_concat(PyListObject *a, PyObject *bb)
return
NULL
;
}
#define b ((PyListObject *)bb)
size
=
Py_SIZE
(
a
)
+
Py_SIZE
(
b
);
if
(
size
<
0
)
if
(
Py_SIZE
(
a
)
>
PY_SSIZE_T_MAX
-
Py_SIZE
(
b
))
return
PyErr_NoMemory
();
size
=
Py_SIZE
(
a
)
+
Py_SIZE
(
b
);
np
=
(
PyListObject
*
)
PyList_New
(
size
);
if
(
np
==
NULL
)
{
return
NULL
;
...
...
@@ -841,18 +841,20 @@ listextend(PyListObject *self, PyObject *b)
return
NULL
;
}
m
=
Py_SIZE
(
self
);
mn
=
m
+
n
;
if
(
mn
>=
m
)
{
if
(
m
>
PY_SSIZE_T_MAX
-
n
)
{
/* m + n overflowed; on the chance that n lied, and there really
* is enough room, ignore it. If n was telling the truth, we'll
* eventually run out of memory during the loop.
*/
}
else
{
mn
=
m
+
n
;
/* Make room. */
if
(
list_resize
(
self
,
mn
)
<
0
)
goto
error
;
/* Make the list sane again. */
Py_SIZE
(
self
)
=
m
;
}
/* Else m + n overflowed; on the chance that n lied, and there really
* is enough room, ignore it. If n was telling the truth, we'll
* eventually run out of memory during the loop.
*/
/* Run iterator to exhaustion. */
for
(;;)
{
...
...
Objects/tupleobject.c
Dosyayı görüntüle @
b93d8637
...
...
@@ -453,9 +453,9 @@ tupleconcat(PyTupleObject *a, PyObject *bb)
return
NULL
;
}
#define b ((PyTupleObject *)bb)
size
=
Py_SIZE
(
a
)
+
Py_SIZE
(
b
);
if
(
size
<
0
)
if
(
Py_SIZE
(
a
)
>
PY_SSIZE_T_MAX
-
Py_SIZE
(
b
))
return
PyErr_NoMemory
();
size
=
Py_SIZE
(
a
)
+
Py_SIZE
(
b
);
np
=
(
PyTupleObject
*
)
PyTuple_New
(
size
);
if
(
np
==
NULL
)
{
return
NULL
;
...
...
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