mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-11 03:26:37 +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>
|
||||
|
||||
* 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 || \
|
||||
(PG_MAJOR_VERSION == 8 && PG_MINOR_VERSION > 1) || \
|
||||
(PG_MAJOR_VERSION == 8 && PG_MINOR_VERSION == 1 && PG_PATCH_VERSION >= 4)
|
||||
return PQescapeByteaConn(conn, from, from_length, to_length);
|
||||
#else
|
||||
#ifdef __GNUC__
|
||||
#warning "YOUR POSTGRESQL VERSION IS TOO OLD AND IT CAN BE INSECURE"
|
||||
#endif
|
||||
return PQescapeBytea(from, from_length, to_length);
|
||||
if (conn)
|
||||
return PQescapeByteaConn(conn, from, from_length, to_length);
|
||||
else
|
||||
#endif
|
||||
return PQescapeBytea(from, from_length, to_length);
|
||||
}
|
||||
#else
|
||||
static unsigned char *
|
||||
|
@ -144,7 +142,7 @@ binary_quote(binaryObject *self)
|
|||
/* escape and build quoted buffer */
|
||||
PyObject_AsCharBuffer(self->wrapped, &buffer, &buffer_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) {
|
||||
PyErr_NoMemory();
|
||||
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_PATCH_VERSION >= 4)
|
||||
int err;
|
||||
return PQescapeStringConn(conn, to, from, len, &err);
|
||||
#else
|
||||
#ifdef __GNUC__
|
||||
#warning "YOUR POSTGRESQL VERSION IS TOO OLD AND IT CAN BE INSECURE"
|
||||
#endif
|
||||
return PQescapeString(to, from, len);
|
||||
if (conn)
|
||||
return PQescapeStringConn(conn, to, from, len, &err);
|
||||
else
|
||||
#endif
|
||||
return PQescapeString(to, from, len);
|
||||
}
|
||||
#else
|
||||
static size_t
|
||||
|
@ -149,7 +147,7 @@ qstring_quote(qstringObject *self)
|
|||
|
||||
Py_BEGIN_ALLOW_THREADS;
|
||||
len = qstring_escape(buffer+1, s, len,
|
||||
((connectionObject*)self->conn)->pgconn);
|
||||
self->conn ? ((connectionObject*)self->conn)->pgconn : NULL);
|
||||
buffer[0] = '\'' ; buffer[len+1] = '\'';
|
||||
Py_END_ALLOW_THREADS;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user