mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-13 04:26:33 +03:00
Fixed segfault in Binary/QString.
This commit is contained in:
parent
cf7701a151
commit
b9fcde1b39
|
@ -1,3 +1,11 @@
|
||||||
|
2006-06-18 Federico Di Gregorio <fog@initd.org>
|
||||||
|
|
||||||
|
* psycopg/adapter_binary.c: same as below.
|
||||||
|
|
||||||
|
* psycopg/adapter_qstring.c: does not segfault anymore if
|
||||||
|
.getquoted() is called without preparing the qstring with
|
||||||
|
the connection.
|
||||||
|
|
||||||
2006-06-15 Federico Di Gregorio <fog@initd.org>
|
2006-06-15 Federico Di Gregorio <fog@initd.org>
|
||||||
|
|
||||||
* psycopg/typecast_basic.c: fixed problem with bogus
|
* psycopg/typecast_basic.c: fixed problem with bogus
|
||||||
|
|
|
@ -44,13 +44,11 @@ binary_escape(unsigned char *from, unsigned int from_length,
|
||||||
#if PG_MAJOR_VERSION > 8 || \
|
#if PG_MAJOR_VERSION > 8 || \
|
||||||
(PG_MAJOR_VERSION == 8 && PG_MINOR_VERSION > 1) || \
|
(PG_MAJOR_VERSION == 8 && PG_MINOR_VERSION > 1) || \
|
||||||
(PG_MAJOR_VERSION == 8 && PG_MINOR_VERSION == 1 && PG_PATCH_VERSION >= 4)
|
(PG_MAJOR_VERSION == 8 && PG_MINOR_VERSION == 1 && PG_PATCH_VERSION >= 4)
|
||||||
return PQescapeByteaConn(conn, from, from_length, to_length);
|
if (conn)
|
||||||
#else
|
return PQescapeByteaConn(conn, from, from_length, to_length);
|
||||||
#ifdef __GNUC__
|
else
|
||||||
#warning "YOUR POSTGRESQL VERSION IS TOO OLD AND IT CAN BE INSECURE"
|
|
||||||
#endif
|
|
||||||
return PQescapeBytea(from, from_length, to_length);
|
|
||||||
#endif
|
#endif
|
||||||
|
return PQescapeBytea(from, from_length, to_length);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static unsigned char *
|
static unsigned char *
|
||||||
|
@ -144,7 +142,7 @@ binary_quote(binaryObject *self)
|
||||||
/* escape and build quoted buffer */
|
/* escape and build quoted buffer */
|
||||||
PyObject_AsCharBuffer(self->wrapped, &buffer, &buffer_len);
|
PyObject_AsCharBuffer(self->wrapped, &buffer, &buffer_len);
|
||||||
to = (char *)binary_escape((unsigned char*)buffer, buffer_len, &len,
|
to = (char *)binary_escape((unsigned char*)buffer, buffer_len, &len,
|
||||||
((connectionObject*)self->conn)->pgconn);
|
self->conn ? ((connectionObject*)self->conn)->pgconn : NULL);
|
||||||
if (to == NULL) {
|
if (to == NULL) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -45,13 +45,11 @@ qstring_escape(char *to, char *from, size_t len, PGconn *conn)
|
||||||
(PG_MAJOR_VERSION == 8 && PG_MINOR_VERSION > 1) || \
|
(PG_MAJOR_VERSION == 8 && PG_MINOR_VERSION > 1) || \
|
||||||
(PG_MAJOR_VERSION == 8 && PG_MINOR_VERSION == 1 && PG_PATCH_VERSION >= 4)
|
(PG_MAJOR_VERSION == 8 && PG_MINOR_VERSION == 1 && PG_PATCH_VERSION >= 4)
|
||||||
int err;
|
int err;
|
||||||
return PQescapeStringConn(conn, to, from, len, &err);
|
if (conn)
|
||||||
#else
|
return PQescapeStringConn(conn, to, from, len, &err);
|
||||||
#ifdef __GNUC__
|
else
|
||||||
#warning "YOUR POSTGRESQL VERSION IS TOO OLD AND IT CAN BE INSECURE"
|
|
||||||
#endif
|
|
||||||
return PQescapeString(to, from, len);
|
|
||||||
#endif
|
#endif
|
||||||
|
return PQescapeString(to, from, len);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static size_t
|
static size_t
|
||||||
|
@ -149,7 +147,7 @@ qstring_quote(qstringObject *self)
|
||||||
|
|
||||||
Py_BEGIN_ALLOW_THREADS;
|
Py_BEGIN_ALLOW_THREADS;
|
||||||
len = qstring_escape(buffer+1, s, len,
|
len = qstring_escape(buffer+1, s, len,
|
||||||
((connectionObject*)self->conn)->pgconn);
|
self->conn ? ((connectionObject*)self->conn)->pgconn : NULL);
|
||||||
buffer[0] = '\'' ; buffer[len+1] = '\'';
|
buffer[0] = '\'' ; buffer[len+1] = '\'';
|
||||||
Py_END_ALLOW_THREADS;
|
Py_END_ALLOW_THREADS;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user