BUG #16330: psql accesses null pointer in connect.c:do_connect - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #16330: psql accesses null pointer in connect.c:do_connect
Date
Msg-id 16330-b34835d83619e25d@postgresql.org
Whole thread Raw
Responses Re: BUG #16330: psql accesses null pointer in connect.c:do_connect  (Michael Paquier <michael@paquier.xyz>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      16330
Logged by:          Hugh Wang
Email address:      hghwng@gmail.com
PostgreSQL version: 12.2
Operating system:   Arch Linux
Description:

If the connection to postmaster is closed, then trying to re-connect to
another one leads to SIGSEGV.

REPRODUCE:
$ psql
-> \conninfo
You are connected to database "hugh" as user "hugh" via socket in
"/run/postgresql" at port "5432".
*shut down server with commands like "systemctl stop postgresql"*
-> \conninfo 
You are currently not connected to a database.
-> \c a b c d
[1]    984978 segmentation fault (core dumped)  psql

ANALYSIS:
PQhost(o_conn) returns NULL, and strcmp(host, NULL) raises SIGSEGV.

SOURCE:
https://github.com/postgres/postgres/blob/master/src/bin/psql/command.c#L3016


pgsql-bugs by date:

Previous
From: Hugh Wang
Date:
Subject: Re: BUG #16321: Memory leaks in PostmasterMain
Next
From: Alexander Lakhin
Date:
Subject: Re: BUG #16329: Valgrind detects an invalid read when building a gistindex with buffering