Issue #27897: Fixed possible crash in sqlite3.Connection.create_collation()

if pass invalid string-like object as a name.  Patch by Xiang Zhang.
This commit is contained in:
Serhiy Storchaka 2016-09-27 00:10:03 +03:00
parent a24d2d8274
commit 407ac47690
3 changed files with 29 additions and 2 deletions

View file

@ -1523,11 +1523,13 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args)
goto finally;
}
if (!PyArg_ParseTuple(args, "O!O:create_collation(name, callback)", &PyUnicode_Type, &name, &callable)) {
if (!PyArg_ParseTuple(args, "UO:create_collation(name, callback)",
&name, &callable)) {
goto finally;
}
uppercase_name = _PyObject_CallMethodId(name, &PyId_upper, "");
uppercase_name = _PyObject_CallMethodIdObjArgs((PyObject *)&PyUnicode_Type,
&PyId_upper, name, NULL);
if (!uppercase_name) {
goto finally;
}