Commit 55a2cc8
committed
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.1 parent b17dbf2 commit 55a2cc8
1 file changed
+12
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1638 | 1638 | | |
1639 | 1639 | | |
1640 | 1640 | | |
1641 | | - | |
| 1641 | + | |
| 1642 | + | |
1642 | 1643 | | |
1643 | | - | |
1644 | | - | |
1645 | | - | |
1646 | | - | |
1647 | | - | |
1648 | | - | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
1649 | 1652 | | |
1650 | 1653 | | |
1651 | 1654 | | |
| |||
1657 | 1660 | | |
1658 | 1661 | | |
1659 | 1662 | | |
1660 | | - | |
1661 | | - | |
| 1663 | + | |
| 1664 | + | |
1662 | 1665 | | |
1663 | 1666 | | |
1664 | 1667 | | |
| |||
0 commit comments