mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-07 12:50:32 +03:00
Piet Delport patches: 3 of 3.
This commit is contained in:
parent
474d8b9d51
commit
1d8af808bf
|
@ -1,5 +1,13 @@
|
||||||
2006-09-23 Federico Di Gregorio <fog@initd.org>
|
2006-09-23 Federico Di Gregorio <fog@initd.org>
|
||||||
|
|
||||||
|
* Applied patch 1/3 from Piet Delport; from his email:
|
||||||
|
psycopg2-Py_ssize_t-input.diff adjusts variables used for parameters
|
||||||
|
and return values. These changes only prevent overflowing on values
|
||||||
|
greater than 32-bits, so they're not as critical as the other two
|
||||||
|
patches. I tried to leave places unchanged where the input size is
|
||||||
|
already constrained to sizeof(int), but i might have missed a few
|
||||||
|
either way, not being too familiar with the codebase.
|
||||||
|
|
||||||
* Applied patch 2/3 from Piet Delport; from his email:
|
* Applied patch 2/3 from Piet Delport; from his email:
|
||||||
psycopg2-Py_ssize_t-output.diff adjusts variables used as outputs
|
psycopg2-Py_ssize_t-output.diff adjusts variables used as outputs
|
||||||
from CPython API calls: without it the calls try to write 64 bits
|
from CPython API calls: without it the calls try to write 64 bits
|
||||||
|
|
|
@ -40,7 +40,7 @@ list_quote(listObject *self)
|
||||||
/* adapt the list by calling adapt() recursively and then wrapping
|
/* adapt the list by calling adapt() recursively and then wrapping
|
||||||
everything into "ARRAY[]" */
|
everything into "ARRAY[]" */
|
||||||
PyObject *tmp = NULL, *str = NULL, *joined = NULL, *res = NULL;
|
PyObject *tmp = NULL, *str = NULL, *joined = NULL, *res = NULL;
|
||||||
int i, len;
|
Py_ssize_t i, len;
|
||||||
|
|
||||||
len = PyList_GET_SIZE(self->wrapped);
|
len = PyList_GET_SIZE(self->wrapped);
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,8 @@ _mogrify(PyObject *var, PyObject *fmt, connectionObject *conn, PyObject **new)
|
||||||
{
|
{
|
||||||
PyObject *key, *value, *n, *item;
|
PyObject *key, *value, *n, *item;
|
||||||
char *d, *c;
|
char *d, *c;
|
||||||
int index = 0, force = 0;
|
Py_ssize_t index = 0;
|
||||||
|
int force = 0;
|
||||||
|
|
||||||
/* from now on we'll use n and replace its value in *new only at the end,
|
/* from now on we'll use n and replace its value in *new only at the end,
|
||||||
just before returning. we also init *new to NULL to exit with an error
|
just before returning. we also init *new to NULL to exit with an error
|
||||||
|
@ -872,7 +873,7 @@ psyco_curs_callproc(cursorObject *self, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
char *procname = NULL, *sql = NULL;
|
char *procname = NULL, *sql = NULL;
|
||||||
long int async = 0;
|
long int async = 0;
|
||||||
int i, nparameters = 0, sl = 0;
|
Py_ssize_t i, nparameters = 0, sl = 0;
|
||||||
PyObject *parameters = NULL;
|
PyObject *parameters = NULL;
|
||||||
PyObject *operation = NULL;
|
PyObject *operation = NULL;
|
||||||
PyObject *res = NULL;
|
PyObject *res = NULL;
|
||||||
|
|
|
@ -586,7 +586,8 @@ _pq_copy_in_v3(cursorObject *curs)
|
||||||
uses the new PQputCopyData() and can detect errors and set the correct
|
uses the new PQputCopyData() and can detect errors and set the correct
|
||||||
exception */
|
exception */
|
||||||
PyObject *o;
|
PyObject *o;
|
||||||
int length = 0, error = 0;
|
Py_ssize_t length = 0;
|
||||||
|
int error = 0;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
o = PyObject_CallMethod(curs->copyfile, "read", "i", curs->copysize);
|
o = PyObject_CallMethod(curs->copyfile, "read", "i", curs->copysize);
|
||||||
|
|
|
@ -267,7 +267,7 @@ int
|
||||||
typecast_add(PyObject *obj, int binary)
|
typecast_add(PyObject *obj, int binary)
|
||||||
{
|
{
|
||||||
PyObject *val;
|
PyObject *val;
|
||||||
int len, i;
|
Py_ssize_t len, i;
|
||||||
|
|
||||||
typecastObject *type = (typecastObject *)obj;
|
typecastObject *type = (typecastObject *)obj;
|
||||||
|
|
||||||
|
@ -302,7 +302,8 @@ typecast_cmp(PyObject *obj1, PyObject* obj2)
|
||||||
typecastObject *self = (typecastObject*)obj1;
|
typecastObject *self = (typecastObject*)obj1;
|
||||||
typecastObject *other = NULL;
|
typecastObject *other = NULL;
|
||||||
PyObject *number = NULL;
|
PyObject *number = NULL;
|
||||||
int i, j, res = -1;
|
Py_ssize_t i, j;
|
||||||
|
int res = -1;
|
||||||
|
|
||||||
if (PyObject_TypeCheck(obj2, &typecastType)) {
|
if (PyObject_TypeCheck(obj2, &typecastType)) {
|
||||||
other = (typecastObject*)obj2;
|
other = (typecastObject*)obj2;
|
||||||
|
@ -505,7 +506,7 @@ typecast_from_c(typecastObject_initlist *type, PyObject *dict)
|
||||||
{
|
{
|
||||||
PyObject *tuple, *base = NULL;
|
PyObject *tuple, *base = NULL;
|
||||||
typecastObject *obj;
|
typecastObject *obj;
|
||||||
int i, len = 0;
|
Py_ssize_t i, len = 0;
|
||||||
|
|
||||||
/* before doing anything else we look for the base */
|
/* before doing anything else we look for the base */
|
||||||
if (type->base) {
|
if (type->base) {
|
||||||
|
@ -538,7 +539,7 @@ typecast_from_c(typecastObject_initlist *type, PyObject *dict)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
typecast_cast(PyObject *obj, char *str, int len, PyObject *curs)
|
typecast_cast(PyObject *obj, char *str, Py_ssize_t len, PyObject *curs)
|
||||||
{
|
{
|
||||||
PyObject *old, *res = NULL;
|
PyObject *old, *res = NULL;
|
||||||
typecastObject *self = (typecastObject *)obj;
|
typecastObject *self = (typecastObject *)obj;
|
||||||
|
|
|
@ -80,6 +80,6 @@ extern PyObject *typecast_from_python(
|
||||||
|
|
||||||
/* the function used to dispatch typecasting calls */
|
/* the function used to dispatch typecasting calls */
|
||||||
extern PyObject *typecast_cast(
|
extern PyObject *typecast_cast(
|
||||||
PyObject *self, char *str, int len, PyObject *curs);
|
PyObject *self, char *str, Py_ssize_t len, PyObject *curs);
|
||||||
|
|
||||||
#endif /* !defined(PSYCOPG_TYPECAST_H) */
|
#endif /* !defined(PSYCOPG_TYPECAST_H) */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user