mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-01-31 09:24:07 +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>
|
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
|
* psycopg/adapter_qstring.c: now quote using PQescapeStringConn if
|
||||||
available.
|
available.
|
||||||
|
|
||||||
|
|
|
@ -41,9 +41,11 @@ 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 (conn)
|
if (conn)
|
||||||
return PQescapeByteaConn(conn, from, from_length, to_length);
|
return PQescapeByteaConn(conn, from, from_length, to_length);
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
return PQescapeBytea(from, from_length, to_length);
|
return PQescapeBytea(from, from_length, to_length);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -42,10 +42,11 @@ 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;
|
int err = 0;
|
||||||
|
#if PG_MAJOR_VERSION >= 8 && PG_MINOR_VERSION >= 1 && PG_PATCH_VERSION >= 4
|
||||||
if (conn)
|
if (conn)
|
||||||
return PQescapeStringConn(conn, to, from, len, &err);
|
return PQescapeStringConn(conn, to, from, len, &err);
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
return PQescapeString(to, from, len);
|
return PQescapeString(to, from, len);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
28
setup.py
28
setup.py
|
@ -61,6 +61,13 @@ if sys.version < '2.2.3':
|
||||||
DistributionMetadata.classifiers = None
|
DistributionMetadata.classifiers = None
|
||||||
DistributionMetadata.download_url = 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):
|
class psycopg_build_ext(build_ext):
|
||||||
"""Conditionally complement the setup.cfg options file.
|
"""Conditionally complement the setup.cfg options file.
|
||||||
|
|
||||||
|
@ -94,13 +101,6 @@ class psycopg_build_ext(build_ext):
|
||||||
self.pg_config = self.DEFAULT_PG_CONFIG
|
self.pg_config = self.DEFAULT_PG_CONFIG
|
||||||
self.mx_include_dir = None
|
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):
|
def get_compiler(self):
|
||||||
"""Return the c compiler to compile extensions.
|
"""Return the c compiler to compile extensions.
|
||||||
|
|
||||||
|
@ -109,6 +109,9 @@ class psycopg_build_ext(build_ext):
|
||||||
"""
|
"""
|
||||||
return self.compiler or get_default_compiler()
|
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):
|
def build_extensions(self):
|
||||||
# Linking against this library causes psycopg2 to crash
|
# Linking against this library causes psycopg2 to crash
|
||||||
# on Python >= 2.4. Maybe related to strdup calls, cfr.
|
# 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.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"))
|
||||||
self.include_dirs.append(self.get_pg_config("includedir-server"))
|
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:
|
except Warning, w:
|
||||||
if self.pg_config == self.DEFAULT_PG_CONFIG:
|
if self.pg_config == self.DEFAULT_PG_CONFIG:
|
||||||
sys.stderr.write("Warning: %s" % str(w))
|
sys.stderr.write("Warning: %s" % str(w))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user