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

Commitfb990ce

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 parent080c4da commitfb990ce

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
@@ -1641,7 +1641,8 @@ do_connect(char *dbname, char *user, char *host, char *port)
16411641
* positional syntax.
16421642
*/
16431643
keep_password=
1644-
((strcmp(user,PQuser(o_conn))==0)&&
1644+
(o_conn&&
1645+
(strcmp(user,PQuser(o_conn))==0)&&
16451646
(!host||strcmp(host,PQhost(o_conn))==0)&&
16461647
(strcmp(port,PQport(o_conn))==0)&&
16471648
!has_connection_string);
@@ -1768,7 +1769,8 @@ do_connect(char *dbname, char *user, char *host, char *port)
17681769
/* Tell the user about the new connection */
17691770
if (!pset.quiet)
17701771
{
1771-
if (param_is_newly_set(PQhost(o_conn),PQhost(pset.db))||
1772+
if (!o_conn||
1773+
param_is_newly_set(PQhost(o_conn),PQhost(pset.db))||
17721774
param_is_newly_set(PQport(o_conn),PQport(pset.db)))
17731775
{
17741776
char*host=PQhost(pset.db);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp