mirror of https://github.com/python/cpython
Even though _Py_Mangle() isn't truly public anyone can call it and
there was no verification that privateobj was a PyString. If it wasn't a string, this could have allowed a NULL pointer to creep in below and crash. I wonder if this should be PyString_CheckExact? Must identifiers be strings or can they be subclasses? Klocwork #275
This commit is contained in:
parent
6f5ff3f3eb
commit
84167d09cd
|
@ -204,8 +204,8 @@ _Py_Mangle(PyObject *privateobj, PyObject *ident)
|
||||||
const char *p, *name = PyString_AsString(ident);
|
const char *p, *name = PyString_AsString(ident);
|
||||||
char *buffer;
|
char *buffer;
|
||||||
size_t nlen, plen;
|
size_t nlen, plen;
|
||||||
if (privateobj == NULL || name == NULL || name[0] != '_' ||
|
if (privateobj == NULL || !PyString_Check(privateobj) ||
|
||||||
name[1] != '_') {
|
name == NULL || name[0] != '_' || name[1] != '_') {
|
||||||
Py_INCREF(ident);
|
Py_INCREF(ident);
|
||||||
return ident;
|
return ident;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue