gh-100370: fix OverflowError in sqlite3.Connection.blobopen for 32-bit builds (#103902)

This commit is contained in:
Erlend E. Aasland 2023-05-07 12:55:31 +02:00 • committed by GitHub
parent cab1298a60
commit a05bad3254
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 9 deletions

View file

@ -228,7 +228,7 @@ PyDoc_STRVAR(blobopen__doc__,
static PyObject *
blobopen_impl(pysqlite_Connection *self, const char *table, const char *col,
int row, int readonly, const char *name);
sqlite3_int64 row, int readonly, const char *name);
static PyObject *
blobopen(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
@ -263,7 +263,7 @@ blobopen(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyO
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3;
const char *table;
const char *col;
int row;
sqlite3_int64 row;
int readonly = 0;
const char *name = "main";
@ -297,8 +297,7 @@ blobopen(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyO
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
row = _PyLong_AsInt(args[2]);
if (row == -1 && PyErr_Occurred()) {
if (!sqlite3_int64_converter(args[2], &row)) {
goto exit;
}
if (!noptargs) {
@ -1666,4 +1665,4 @@ exit:
#ifndef DESERIALIZE_METHODDEF
#define DESERIALIZE_METHODDEF
#endif /* !defined(DESERIALIZE_METHODDEF) */
/*[clinic end generated code: output=8b03149c115ee6da input=a9049054013a1b77]*/
/*[clinic end generated code: output=834a99827555bf1a input=a9049054013a1b77]*/