From: Benjamin Peterson Date: Sat, 23 Aug 2008 20:32:27 +0000 (+0000) Subject: #3643 add more checks to _testcapi to prevent segfaults X-Git-Tag: v3.0rc1~184 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6784eb79c91b63f468f91dad61c39932dfaad58a;p=python #3643 add more checks to _testcapi to prevent segfaults Author: Victor Stinner Reviewer: Benjamin Peterson --- diff --git a/Misc/NEWS b/Misc/NEWS index 83f1c96149..ae40187951 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -17,6 +17,12 @@ Core and Builtins Library ------- +Extension Modules +----------------- + +- Issue #3643: Added a few more checks to _testcapi to prevent segfaults by + exploitation of poor argument checking. + What's new in Python 3.0b3? =========================== diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 494937aa4e..995d789cfa 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -961,6 +961,10 @@ exception_print(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "O:exception_print", &value)) return NULL; + if (!PyExceptionInstance_Check(value)) { + PyErr_Format(PyExc_TypeError, "an exception instance is required"); + return NULL; + } tb = PyException_GetTraceback(value); PyErr_Display((PyObject *) Py_TYPE(value), value, tb);