Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit49008d6

Browse files
committed
Fix null pointer dereference in "\c" psql command.
The psql crash happened when no current connection existed. (The secondnew check is optional given today's undocumented NULL argument handlingin PQhost() etc.) Back-patch to 9.0 (all supported versions).
1 parentdca992d commit49008d6

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
@@ -1591,7 +1591,8 @@ do_connect(char *dbname, char *user, char *host, char *port)
15911591
* syntax.
15921592
*/
15931593
keep_password=
1594-
((strcmp(user,PQuser(o_conn))==0)&&
1594+
(o_conn&&
1595+
(strcmp(user,PQuser(o_conn))==0)&&
15951596
(!host||strcmp(host,PQhost(o_conn))==0)&&
15961597
(strcmp(port,PQport(o_conn))==0)&&
15971598
!has_connection_string);
@@ -1718,7 +1719,8 @@ do_connect(char *dbname, char *user, char *host, char *port)
17181719
/* Tell the user about the new connection */
17191720
if (!pset.quiet)
17201721
{
1721-
if (param_is_newly_set(PQhost(o_conn),PQhost(pset.db))||
1722+
if (!o_conn||
1723+
param_is_newly_set(PQhost(o_conn),PQhost(pset.db))||
17221724
param_is_newly_set(PQport(o_conn),PQport(pset.db)))
17231725
{
17241726
char*host=PQhost(pset.db);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp