summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite/connection.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-10-01 05:24:55 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-10-01 05:24:55 (GMT)
commit5170c16d2105ef5a1a049d2fd8a05439f6b47229 (patch)
treebdee43f7fa5130ffd9b3a28a31e2e15988683a54 /Modules/_sqlite/connection.c
parentdace77c5306fc68ec754b3c73cdba29bfa10444f (diff)
downloadcpython-5170c16d2105ef5a1a049d2fd8a05439f6b47229.zip
cpython-5170c16d2105ef5a1a049d2fd8a05439f6b47229.tar.gz
cpython-5170c16d2105ef5a1a049d2fd8a05439f6b47229.tar.bz2
Issue #27897: Fixed possible crash in sqlite3.Connection.create_collation()
if pass invalid string-like object as a name. Original patch by Xiang Zhang.
Diffstat (limited to 'Modules/_sqlite/connection.c')
-rw-r--r--Modules/_sqlite/connection.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 24b39c1..e62e4d9 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -1476,16 +1476,18 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args)
goto finally;
}
- if (!PyArg_ParseTuple(args, "O!O:create_collation(name, callback)", &PyString_Type, &name, &callable)) {
+ if (!PyArg_ParseTuple(args, "SO:create_collation(name, callback)",
+ &name, &callable)) {
goto finally;
}
- uppercase_name = PyObject_CallMethod(name, "upper", "");
+ uppercase_name = PyObject_CallMethod((PyObject *)&PyString_Type,
+ "upper", "O", name);
if (!uppercase_name) {
goto finally;
}
- chk = PyString_AsString(uppercase_name);
+ chk = PyString_AS_STRING(uppercase_name);
while (*chk) {
if ((*chk >= '0' && *chk <= '9')
|| (*chk >= 'A' && *chk <= 'Z')