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

Commit37e1cce

Browse files
committed
libpq: Fix SNI host handling
Fix handling of NULL host name (possibly by using hostaddr). Itpreviously crashed. Also, we should look at connhost, not pghost, tohandle multi-host specifications.Also remove an unnecessary SSL_CTX_free().Reported-by: Jacob Champion <pchampion@vmware.com>Reviewed-by: Michael Paquier <michael@paquier.xyz>Discussion:https://www.postgresql.org/message-id/504c276ab6eee000bb23d571ea9b0ced4250774e.camel@vmware.com
1 parenteab8195 commit37e1cce

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

‎src/interfaces/libpq/fe-secure-openssl.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,20 +1087,24 @@ initialize_SSL(PGconn *conn)
10871087
* Per RFC 6066, do not set it if the host is a literal IP address (IPv4
10881088
* or IPv6).
10891089
*/
1090-
if (conn->sslsni&&conn->sslsni[0]&&
1091-
!(strspn(conn->pghost,"0123456789.")==strlen(conn->pghost)||
1092-
strchr(conn->pghost,':')))
1090+
if (conn->sslsni&&conn->sslsni[0])
10931091
{
1094-
if (SSL_set_tlsext_host_name(conn->ssl,conn->pghost)!=1)
1092+
constchar*host=conn->connhost[conn->whichhost].host;
1093+
1094+
if (host&&host[0]&&
1095+
!(strspn(host,"0123456789.")==strlen(host)||
1096+
strchr(host,':')))
10951097
{
1096-
char*err=SSLerrmessage(ERR_get_error());
1098+
if (SSL_set_tlsext_host_name(conn->ssl,host)!=1)
1099+
{
1100+
char*err=SSLerrmessage(ERR_get_error());
10971101

1098-
appendPQExpBuffer(&conn->errorMessage,
1099-
libpq_gettext("could not set SSL Server Name Indication (SNI): %s\n"),
1100-
err);
1101-
SSLerrfree(err);
1102-
SSL_CTX_free(SSL_context);
1103-
return-1;
1102+
appendPQExpBuffer(&conn->errorMessage,
1103+
libpq_gettext("could not set SSL Server Name Indication (SNI): %s\n"),
1104+
err);
1105+
SSLerrfree(err);
1106+
return-1;
1107+
}
11041108
}
11051109
}
11061110

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp