mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-10 19:16:34 +03:00
Final of 8.1.4 securiy patch.
This commit is contained in:
parent
5f8eddfcab
commit
ec877b0ef9
|
@ -1,5 +1,8 @@
|
|||
2006-05-24 Federico Di Gregorio <fog@initd.org>
|
||||
|
||||
* Enabled 8.1.4 security fix only when the version is >= 8.1.4, fall
|
||||
back to old code otherwise.
|
||||
|
||||
* psycopg/adapter_qstring.c: now quote using PQescapeStringConn if
|
||||
available.
|
||||
|
||||
|
|
|
@ -41,9 +41,11 @@ static unsigned char *
|
|||
binary_escape(unsigned char *from, unsigned int from_length,
|
||||
unsigned int *to_length, PGconn *conn)
|
||||
{
|
||||
#if PG_MAJOR_VERSION >= 8 && PG_MINOR_VERSION >= 1 && PG_PATCH_VERSION >= 4
|
||||
if (conn)
|
||||
return PQescapeByteaConn(conn, from, from_length, to_length);
|
||||
else
|
||||
#endif
|
||||
return PQescapeBytea(from, from_length, to_length);
|
||||
}
|
||||
#else
|
||||
|
|
|
@ -42,10 +42,11 @@ static size_t
|
|||
qstring_escape(char *to, char *from, size_t len, PGconn *conn)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
#if PG_MAJOR_VERSION >= 8 && PG_MINOR_VERSION >= 1 && PG_PATCH_VERSION >= 4
|
||||
if (conn)
|
||||
return PQescapeStringConn(conn, to, from, len, &err);
|
||||
else
|
||||
#endif
|
||||
return PQescapeString(to, from, len);
|
||||
}
|
||||
#else
|
||||
|
|
28
setup.py
28
setup.py
|
@ -61,6 +61,13 @@ if sys.version < '2.2.3':
|
|||
DistributionMetadata.classifiers = None
|
||||
DistributionMetadata.download_url = None
|
||||
|
||||
def get_pg_config(kind, pg_config="pg_config"):
|
||||
p = popen2.popen3(pg_config + " --" + kind)
|
||||
r = p[0].readline().strip()
|
||||
if not r:
|
||||
raise Warning(p[2].readline())
|
||||
return r
|
||||
|
||||
class psycopg_build_ext(build_ext):
|
||||
"""Conditionally complement the setup.cfg options file.
|
||||
|
||||
|
@ -93,13 +100,6 @@ class psycopg_build_ext(build_ext):
|
|||
self.pgdir = None
|
||||
self.pg_config = self.DEFAULT_PG_CONFIG
|
||||
self.mx_include_dir = None
|
||||
|
||||
def get_pg_config(self, kind):
|
||||
p = popen2.popen3(self.pg_config + " --" + kind)
|
||||
r = p[0].readline().strip()
|
||||
if not r:
|
||||
raise Warning(p[2].readline())
|
||||
return r
|
||||
|
||||
def get_compiler(self):
|
||||
"""Return the c compiler to compile extensions.
|
||||
|
@ -109,6 +109,9 @@ class psycopg_build_ext(build_ext):
|
|||
"""
|
||||
return self.compiler or get_default_compiler()
|
||||
|
||||
def get_pg_config(self, kind):
|
||||
return get_pg_config(kind, self.pg_config)
|
||||
|
||||
def build_extensions(self):
|
||||
# Linking against this library causes psycopg2 to crash
|
||||
# on Python >= 2.4. Maybe related to strdup calls, cfr.
|
||||
|
@ -149,6 +152,17 @@ class psycopg_build_ext(build_ext):
|
|||
self.library_dirs.append(self.get_pg_config("libdir"))
|
||||
self.include_dirs.append(self.get_pg_config("includedir"))
|
||||
self.include_dirs.append(self.get_pg_config("includedir-server"))
|
||||
try:
|
||||
# Here we take a conservative approach: we suppose that
|
||||
# *at least* PostgreSQL 7.4 is available (this is the only
|
||||
# 7.x series supported by psycopg 2)
|
||||
pgversion = self.get_pg_config("version").split()[1]
|
||||
pgmajor, pgminor, pgpatch = pgversion.split('.')
|
||||
except:
|
||||
pgmajor, pgminor, pgpatch = 7, 4, 0
|
||||
define_macros.append(("PG_MAJOR_VERSION", pgmajor))
|
||||
define_macros.append(("PG_MINOR_VERSION", pgminor))
|
||||
define_macros.append(("PG_PATCH_VERSION", pgpatch))
|
||||
except Warning, w:
|
||||
if self.pg_config == self.DEFAULT_PG_CONFIG:
|
||||
sys.stderr.write("Warning: %s" % str(w))
|
||||
|
|
Loading…
Reference in New Issue
Block a user