Better PostgreSQL version check.

This commit is contained in:
Federico Di Gregorio 2006-05-26 05:22:49 +00:00
parent ec877b0ef9
commit bfb00b86fd
3 changed files with 19 additions and 11 deletions

View File

@ -1,3 +1,7 @@
2006-05-26 Federico Di Gregorio <fog@initd.org>
* Applied better PostgreSQL patch from AA.
2006-05-24 Federico Di Gregorio <fog@initd.org> 2006-05-24 Federico Di Gregorio <fog@initd.org>
* Enabled 8.1.4 security fix only when the version is >= 8.1.4, fall * Enabled 8.1.4 security fix only when the version is >= 8.1.4, fall

View File

@ -41,12 +41,14 @@ static unsigned char *
binary_escape(unsigned char *from, unsigned int from_length, binary_escape(unsigned char *from, unsigned int from_length,
unsigned int *to_length, PGconn *conn) unsigned int *to_length, PGconn *conn)
{ {
#if PG_MAJOR_VERSION >= 8 && PG_MINOR_VERSION >= 1 && PG_PATCH_VERSION >= 4 #if PG_MAJOR_VERSION > 8 || \
if (conn) (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); return PQescapeByteaConn(conn, from, from_length, to_length);
else #else
#endif #warning "YOUR POSTGRESQL VERSION IS TOO OLD AND IT CAN BE INSECURE"
return PQescapeBytea(from, from_length, to_length); return PQescapeBytea(from, from_length, to_length);
#endif
} }
#else #else
static unsigned char * static unsigned char *

View File

@ -41,13 +41,15 @@
static size_t static size_t
qstring_escape(char *to, char *from, size_t len, PGconn *conn) qstring_escape(char *to, char *from, size_t len, PGconn *conn)
{ {
int err = 0; #if PG_MAJOR_VERSION > 8 || \
#if PG_MAJOR_VERSION >= 8 && PG_MINOR_VERSION >= 1 && PG_PATCH_VERSION >= 4 (PG_MAJOR_VERSION == 8 && PG_MINOR_VERSION > 1) || \
if (conn) (PG_MAJOR_VERSION == 8 && PG_MINOR_VERSION == 1 && PG_PATCH_VERSION >= 4)
int err;
return PQescapeStringConn(conn, to, from, len, &err); return PQescapeStringConn(conn, to, from, len, &err);
else #else
#endif #warning "YOUR POSTGRESQL VERSION IS TOO OLD AND IT CAN BE INSECURE"
return PQescapeString(to, from, len); return PQescapeString(to, from, len);
#endif
} }
#else #else
static size_t static size_t