pgsql: Be more paranoid about null return values from libpq status func

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Be more paranoid about null return values from libpq status func
Date: 2015-11-25 22:32:19
Message-ID: E1a1ibr-00085P-Q1@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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_3_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/64b7079e50cc75fc0e8730793b4a66bfb7388de2

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

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2015-11-26 18:23:27 pgsql: Fix failure to consider failure cases in GetComboCommandId().
Previous Message Tom Lane 2015-11-25 21:06:02 pgsql: Improve div_var_fast(), mostly by making comments better.