Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
64aafeb4
Commit
64aafeb4
authored
Apr 13, 2013
by
Mark Dickinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #16447: Fix potential segfault when setting __name__ on a class.
parent
eff64447
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
1 deletion
+21
-1
Lib/test/test_descr.py
Lib/test/test_descr.py
+14
-0
Misc/NEWS
Misc/NEWS
+3
-0
Objects/typeobject.c
Objects/typeobject.c
+4
-1
No files found.
Lib/test/test_descr.py
View file @
64aafeb4
...
...
@@ -3997,6 +3997,20 @@ order (MRO) for bases """
C
.
__name__
=
'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
:
pass
C
.
__name__
=
Nasty
(
"abc"
)
C
.
__name__
=
"normal"
def
test_subclass_right_op
(
self
):
# Testing correct dispatch of subclass overloading __r<op>__...
...
...
Misc/NEWS
View file @
64aafeb4
...
...
@@ -12,6 +12,9 @@ What's New in Python 3.3.2?
Core and Builtins
-----------------
- Issue #16447: Fixed potential segmentation fault when setting __name__ on a
class.
- Issue #17669: Fix crash involving finalization of generators using yield from.
- Issue #17619: Make input() check for Ctrl-C correctly on Windows.
...
...
Objects/typeobject.c
View file @
64aafeb4
...
...
@@ -298,10 +298,13 @@ type_set_name(PyTypeObject *type, PyObject *value, void *context)
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
;
type
->
tp_name
=
tp_name
;
Py_DECREF
(
tmp
);
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