summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite/statement.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-02-07 15:03:46 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-02-07 15:03:46 (GMT)
commit2efdc90b0f49866d857a5b3dc21b7c791f7a0aeb (patch)
tree5a929d957c94083e8ab89ca35cf05d7f00cc19e3 /Modules/_sqlite/statement.c
parent03ee12ed7251b6b251d55d708a22616ed2538b19 (diff)
parent3cf96ac2484d093bea17610480efd0e88301f72a (diff)
downloadcpython-2efdc90b0f49866d857a5b3dc21b7c791f7a0aeb.zip
cpython-2efdc90b0f49866d857a5b3dc21b7c791f7a0aeb.tar.gz
cpython-2efdc90b0f49866d857a5b3dc21b7c791f7a0aeb.tar.bz2
Issue #17073: Fix some integer overflows in sqlite3 module.
Diffstat (limited to 'Modules/_sqlite/statement.c')
-rw-r--r--Modules/_sqlite/statement.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c
index 9884860..471a067 100644
--- a/Modules/_sqlite/statement.c
+++ b/Modules/_sqlite/statement.c
@@ -26,6 +26,7 @@
#include "connection.h"
#include "microprotocols.h"
#include "prepare_protocol.h"
+#include "util.h"
#include "sqlitecompat.h"
/* prototypes */
@@ -90,7 +91,6 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con
int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObject* parameter)
{
int rc = SQLITE_OK;
- PY_LONG_LONG longlongval;
const char* buffer;
char* string;
Py_ssize_t buflen;
@@ -120,11 +120,14 @@ int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObjec
}
switch (paramtype) {
- case TYPE_LONG:
- /* in the overflow error case, longval/longlongval is -1, and an exception is set */
- longlongval = PyLong_AsLongLong(parameter);
- rc = sqlite3_bind_int64(self->st, pos, (sqlite_int64)longlongval);
+ case TYPE_LONG: {
+ sqlite_int64 value = _pysqlite_long_as_int64(parameter);
+ if (value == -1 && PyErr_Occurred())
+ rc = -1;
+ else
+ rc = sqlite3_bind_int64(self->st, pos, value);
break;
+ }
case TYPE_FLOAT:
rc = sqlite3_bind_double(self->st, pos, PyFloat_AsDouble(parameter));
break;