pgsql: Avoid improbable null pointer dereference in pgpassfileWarning()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Avoid improbable null pointer dereference in pgpassfileWarning()
Date: 2017-02-03 00:49:23
Message-ID: E1cZS43-0007Ee-W3@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Avoid improbable null pointer dereference in pgpassfileWarning().

Coverity complained that we might pass a null pointer to strcmp()
if PQresultErrorField were to return NULL. That shouldn't be possible,
since the server is supposed to always provide some SQLSTATE or other
in an error message. But we usually defend against such hazards, and
it only takes a little more code to do so here.

There's no good reason to think this is a live bug, so no back-patch.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/8ac0365c22f20dcd2a6b6752b95b665ada83e858

Modified Files
--------------
src/interfaces/libpq/fe-connect.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2017-02-03 01:16:23 pgsql: Clean up psql's behavior for a few more control variables.
Previous Message Tom Lane 2017-02-03 00:11:49 pgsql: Fix placement of initPlans when forcibly materializing a subplan