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
f794b143
Kaydet (Commit)
f794b143
authored
Nis 13, 2013
tarafından
Mark Dickinson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #16447: Fix potential segfault when setting __name__ on a class.
üst
6fa83f99
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
1 deletion
+22
-1
test_descr.py
Lib/test/test_descr.py
+14
-0
NEWS
Misc/NEWS
+3
-0
typeobject.c
Objects/typeobject.c
+5
-1
No files found.
Lib/test/test_descr.py
Dosyayı görüntüle @
f794b143
...
@@ -4136,6 +4136,20 @@ order (MRO) for bases """
...
@@ -4136,6 +4136,20 @@ order (MRO) for bases """
C
.
__name__
=
'D.E'
C
.
__name__
=
'D.E'
self
.
assertEqual
((
C
.
__module__
,
C
.
__name__
),
(
mod
,
'D.E'
))
self
.
assertEqual
((
C
.
__module__
,
C
.
__name__
),
(
mod
,
'D.E'
))
def
test_evil_type_name
(
self
):
# A badly placed Py_DECREF in type_set_name led to arbitrary code
# execution while the type structure was not in a sane state, and a
# possible segmentation fault as a result. See bug #16447.
class
Nasty
(
str
):
def
__del__
(
self
):
C
.
__name__
=
"other"
class
C
(
object
):
pass
C
.
__name__
=
Nasty
(
"abc"
)
C
.
__name__
=
"normal"
def
test_subclass_right_op
(
self
):
def
test_subclass_right_op
(
self
):
# Testing correct dispatch of subclass overloading __r<op>__...
# Testing correct dispatch of subclass overloading __r<op>__...
...
...
Misc/NEWS
Dosyayı görüntüle @
f794b143
...
@@ -17,6 +17,9 @@ Build
...
@@ -17,6 +17,9 @@ Build
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #16447: Fixed potential segmentation fault when setting __name__ on a
class.
- Issue #17610: Don'
t
rely
on
non
-
standard
behavior
of
the
C
qsort
()
function
.
- Issue #17610: Don'
t
rely
on
non
-
standard
behavior
of
the
C
qsort
()
function
.
Library
Library
...
...
Objects/typeobject.c
Dosyayı görüntüle @
f794b143
...
@@ -225,6 +225,7 @@ static int
...
@@ -225,6 +225,7 @@ static int
type_set_name
(
PyTypeObject
*
type
,
PyObject
*
value
,
void
*
context
)
type_set_name
(
PyTypeObject
*
type
,
PyObject
*
value
,
void
*
context
)
{
{
PyHeapTypeObject
*
et
;
PyHeapTypeObject
*
et
;
PyObject
*
tmp
;
if
(
!
(
type
->
tp_flags
&
Py_TPFLAGS_HEAPTYPE
))
{
if
(
!
(
type
->
tp_flags
&
Py_TPFLAGS_HEAPTYPE
))
{
PyErr_Format
(
PyExc_TypeError
,
PyErr_Format
(
PyExc_TypeError
,
...
@@ -253,10 +254,13 @@ type_set_name(PyTypeObject *type, PyObject *value, void *context)
...
@@ -253,10 +254,13 @@ type_set_name(PyTypeObject *type, PyObject *value, void *context)
Py_INCREF
(
value
);
Py_INCREF
(
value
);
Py_DECREF
(
et
->
ht_name
);
/* Wait until et is a sane state before Py_DECREF'ing the old et->ht_name
value. (Bug #16447.) */
tmp
=
et
->
ht_name
;
et
->
ht_name
=
value
;
et
->
ht_name
=
value
;
type
->
tp_name
=
PyString_AS_STRING
(
value
);
type
->
tp_name
=
PyString_AS_STRING
(
value
);
Py_DECREF
(
tmp
);
return
0
;
return
0
;
}
}
...
...
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