pgsql: Be more paranoid about null return values from libpq status func - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Be more paranoid about null return values from libpq status func
Date
Msg-id E1a1ibr-00085S-QG@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Be more paranoid about null return values from libpq status functions.

PQhost() can return NULL in non-error situations, namely when a Unix-socket
connection has been selected by default.  That behavior is a tad debatable
perhaps, but for the moment we should make sure that psql copes with it.
Unfortunately, do_connect() failed to: it could pass a NULL pointer to
strcmp(), resulting in crashes on most platforms.  This was reported as a
security issue by ChenQin of Topsec Security Team, but the consensus of
the security list is that it's just a garden-variety bug with no security
implications.

For paranoia's sake, I made the keep_password test not trust PQuser or
PQport either, even though I believe those will never return NULL given
a valid PGconn.

Back-patch to all supported branches.

Branch
------
REL9_2_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/d44b4deaad9f347c2e83ab50c7252f14fad1ef63

Modified Files
--------------
src/bin/psql/command.c |   23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Be more paranoid about null return values from libpq status func
Next
From: Tom Lane
Date:
Subject: pgsql: Be more paranoid about null return values from libpq status func