Skip to content

Commit eb1525e

Browse files
committed
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).
1 parent 58c58d1 commit eb1525e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/bin/psql/command.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,7 +1627,8 @@ do_connect(char *dbname, char *user, char *host, char *port)
16271627
* syntax.
16281628
*/
16291629
keep_password =
1630-
((strcmp(user, PQuser(o_conn)) == 0) &&
1630+
(o_conn &&
1631+
(strcmp(user, PQuser(o_conn)) == 0) &&
16311632
(!host || strcmp(host, PQhost(o_conn)) == 0) &&
16321633
(strcmp(port, PQport(o_conn)) == 0) &&
16331634
!has_connection_string);
@@ -1754,7 +1755,8 @@ do_connect(char *dbname, char *user, char *host, char *port)
17541755
/* Tell the user about the new connection */
17551756
if (!pset.quiet)
17561757
{
1757-
if (param_is_newly_set(PQhost(o_conn), PQhost(pset.db)) ||
1758+
if (!o_conn ||
1759+
param_is_newly_set(PQhost(o_conn), PQhost(pset.db)) ||
17581760
param_is_newly_set(PQport(o_conn), PQport(pset.db)))
17591761
{
17601762
char *host = PQhost(pset.db);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy