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
bc4ded95
Commit
bc4ded95
authored
Dec 24, 2015
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #24103: Fixed possible use after free in ElementTree.XMLPullParser.
parent
5a57ade5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
19 deletions
+15
-19
Misc/NEWS
Misc/NEWS
+2
-0
Modules/_elementtree.c
Modules/_elementtree.c
+13
-19
No files found.
Misc/NEWS
View file @
bc4ded95
...
@@ -31,6 +31,8 @@ Core and Builtins
...
@@ -31,6 +31,8 @@ Core and Builtins
Library
Library
-------
-------
- Issue #24103: Fixed possible use after free in ElementTree.XMLPullParser.
- Issue #25860: os.fwalk() no longer skips remaining directories when error
- Issue #25860: os.fwalk() no longer skips remaining directories when error
occurs. Original patch by Samson Lee.
occurs. Original patch by Samson Lee.
...
...
Modules/_elementtree.c
View file @
bc4ded95
...
@@ -3598,7 +3598,7 @@ _elementtree_XMLParser__setevents_impl(XMLParserObject *self,
...
@@ -3598,7 +3598,7 @@ _elementtree_XMLParser__setevents_impl(XMLParserObject *self,
/*[clinic end generated code: output=1440092922b13ed1 input=59db9742910c6174]*/
/*[clinic end generated code: output=1440092922b13ed1 input=59db9742910c6174]*/
{
{
/* activate element event reporting */
/* activate element event reporting */
Py_ssize_t
i
,
seqlen
;
Py_ssize_t
i
;
TreeBuilderObject
*
target
;
TreeBuilderObject
*
target
;
PyObject
*
events_seq
;
PyObject
*
events_seq
;
...
@@ -3614,8 +3614,7 @@ _elementtree_XMLParser__setevents_impl(XMLParserObject *self,
...
@@ -3614,8 +3614,7 @@ _elementtree_XMLParser__setevents_impl(XMLParserObject *self,
target
=
(
TreeBuilderObject
*
)
self
->
target
;
target
=
(
TreeBuilderObject
*
)
self
->
target
;
Py_INCREF
(
events_queue
);
Py_INCREF
(
events_queue
);
Py_XDECREF
(
target
->
events
);
Py_SETREF
(
target
->
events
,
events_queue
);
target
->
events
=
events_queue
;
/* clear out existing events */
/* clear out existing events */
Py_CLEAR
(
target
->
start_event_obj
);
Py_CLEAR
(
target
->
start_event_obj
);
...
@@ -3634,46 +3633,41 @@ _elementtree_XMLParser__setevents_impl(XMLParserObject *self,
...
@@ -3634,46 +3633,41 @@ _elementtree_XMLParser__setevents_impl(XMLParserObject *self,
return
NULL
;
return
NULL
;
}
}
seqlen
=
PySequence_Size
(
events_seq
);
for
(
i
=
0
;
i
<
PySequence_Size
(
events_seq
);
++
i
)
{
for
(
i
=
0
;
i
<
seqlen
;
++
i
)
{
PyObject
*
event_name_obj
=
PySequence_Fast_GET_ITEM
(
events_seq
,
i
);
PyObject
*
event_name_obj
=
PySequence_Fast_GET_ITEM
(
events_seq
,
i
);
char
*
event_name
=
NULL
;
char
*
event_name
=
NULL
;
if
(
PyUnicode_Check
(
event_name_obj
))
{
if
(
PyUnicode_Check
(
event_name_obj
))
{
event_name
=
_PyUnicode_AsString
(
event_name_obj
);
event_name
=
PyUnicode_AsUTF8
(
event_name_obj
);
}
else
if
(
PyBytes_Check
(
event_name_obj
))
{
}
else
if
(
PyBytes_Check
(
event_name_obj
))
{
event_name
=
PyBytes_AS_STRING
(
event_name_obj
);
event_name
=
PyBytes_AS_STRING
(
event_name_obj
);
}
}
if
(
event_name
==
NULL
)
{
if
(
event_name
==
NULL
)
{
Py_DECREF
(
events_seq
);
Py_DECREF
(
events_seq
);
PyErr_Format
(
PyExc_ValueError
,
"invalid events sequence"
);
PyErr_Format
(
PyExc_ValueError
,
"invalid events sequence"
);
return
NULL
;
return
NULL
;
}
else
if
(
strcmp
(
event_name
,
"start"
)
==
0
)
{
}
Py_INCREF
(
event_name_obj
);
Py_INCREF
(
event_name_obj
);
target
->
start_event_obj
=
event_name_obj
;
if
(
strcmp
(
event_name
,
"start"
)
==
0
)
{
Py_SETREF
(
target
->
start_event_obj
,
event_name_obj
);
}
else
if
(
strcmp
(
event_name
,
"end"
)
==
0
)
{
}
else
if
(
strcmp
(
event_name
,
"end"
)
==
0
)
{
Py_INCREF
(
event_name_obj
);
Py_SETREF
(
target
->
end_event_obj
,
event_name_obj
);
Py_XDECREF
(
target
->
end_event_obj
);
target
->
end_event_obj
=
event_name_obj
;
}
else
if
(
strcmp
(
event_name
,
"start-ns"
)
==
0
)
{
}
else
if
(
strcmp
(
event_name
,
"start-ns"
)
==
0
)
{
Py_INCREF
(
event_name_obj
);
Py_SETREF
(
target
->
start_ns_event_obj
,
event_name_obj
);
Py_XDECREF
(
target
->
start_ns_event_obj
);
target
->
start_ns_event_obj
=
event_name_obj
;
EXPAT
(
SetNamespaceDeclHandler
)(
EXPAT
(
SetNamespaceDeclHandler
)(
self
->
parser
,
self
->
parser
,
(
XML_StartNamespaceDeclHandler
)
expat_start_ns_handler
,
(
XML_StartNamespaceDeclHandler
)
expat_start_ns_handler
,
(
XML_EndNamespaceDeclHandler
)
expat_end_ns_handler
(
XML_EndNamespaceDeclHandler
)
expat_end_ns_handler
);
);
}
else
if
(
strcmp
(
event_name
,
"end-ns"
)
==
0
)
{
}
else
if
(
strcmp
(
event_name
,
"end-ns"
)
==
0
)
{
Py_INCREF
(
event_name_obj
);
Py_SETREF
(
target
->
end_ns_event_obj
,
event_name_obj
);
Py_XDECREF
(
target
->
end_ns_event_obj
);
target
->
end_ns_event_obj
=
event_name_obj
;
EXPAT
(
SetNamespaceDeclHandler
)(
EXPAT
(
SetNamespaceDeclHandler
)(
self
->
parser
,
self
->
parser
,
(
XML_StartNamespaceDeclHandler
)
expat_start_ns_handler
,
(
XML_StartNamespaceDeclHandler
)
expat_start_ns_handler
,
(
XML_EndNamespaceDeclHandler
)
expat_end_ns_handler
(
XML_EndNamespaceDeclHandler
)
expat_end_ns_handler
);
);
}
else
{
}
else
{
Py_DECREF
(
event_name_obj
);
Py_DECREF
(
events_seq
);
Py_DECREF
(
events_seq
);
PyErr_Format
(
PyExc_ValueError
,
"unknown event '%s'"
,
event_name
);
PyErr_Format
(
PyExc_ValueError
,
"unknown event '%s'"
,
event_name
);
return
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