mirror of
https://github.com/postgres/postgres.git
synced 2025-05-18 17:41:14 +03:00
Fix null pointer dereference in "\c" psql command.
The psql crash happened when no current connection existed. (The second new check is optional given today's undocumented NULL argument handling in PQhost() etc.) Back-patch to 9.0 (all supported versions).
This commit is contained in:
parent
dca992d8b0
commit
49008d6450
@ -1591,7 +1591,8 @@ do_connect(char *dbname, char *user, char *host, char *port)
|
|||||||
* syntax.
|
* syntax.
|
||||||
*/
|
*/
|
||||||
keep_password =
|
keep_password =
|
||||||
((strcmp(user, PQuser(o_conn)) == 0) &&
|
(o_conn &&
|
||||||
|
(strcmp(user, PQuser(o_conn)) == 0) &&
|
||||||
(!host || strcmp(host, PQhost(o_conn)) == 0) &&
|
(!host || strcmp(host, PQhost(o_conn)) == 0) &&
|
||||||
(strcmp(port, PQport(o_conn)) == 0) &&
|
(strcmp(port, PQport(o_conn)) == 0) &&
|
||||||
!has_connection_string);
|
!has_connection_string);
|
||||||
@ -1718,7 +1719,8 @@ do_connect(char *dbname, char *user, char *host, char *port)
|
|||||||
/* Tell the user about the new connection */
|
/* Tell the user about the new connection */
|
||||||
if (!pset.quiet)
|
if (!pset.quiet)
|
||||||
{
|
{
|
||||||
if (param_is_newly_set(PQhost(o_conn), PQhost(pset.db)) ||
|
if (!o_conn ||
|
||||||
|
param_is_newly_set(PQhost(o_conn), PQhost(pset.db)) ||
|
||||||
param_is_newly_set(PQport(o_conn), PQport(pset.db)))
|
param_is_newly_set(PQport(o_conn), PQport(pset.db)))
|
||||||
{
|
{
|
||||||
char *host = PQhost(pset.db);
|
char *host = PQhost(pset.db);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user