libpq-internal-PQhost-usage-1.patch
text/x-diff
Filename: libpq-internal-PQhost-usage-1.patch
Type: text/x-diff
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/interfaces/libpq/fe-auth.c | 2 | 2 |
| src/interfaces/libpq/fe-secure-common.c | 9 | 2 |
diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c
index 3b2073a..09012c5 100644
--- a/src/interfaces/libpq/fe-auth.c
+++ b/src/interfaces/libpq/fe-auth.c
@@ -199,7 +199,7 @@ pg_GSS_startup(PGconn *conn, int payloadlen)
min_stat;
int maxlen;
gss_buffer_desc temp_gbuf;
- char *host = PQhost(conn);
+ char *host = conn->connhost[conn->whichhost].host;
if (!(host && host[0] != '\0'))
{
@@ -414,7 +414,7 @@ pg_SSPI_startup(PGconn *conn, int use_negotiate, int payloadlen)
{
SECURITY_STATUS r;
TimeStamp expire;
- char *host = PQhost(conn);
+ char *host = conn->connhost[conn->whichhost].host;
if (conn->sspictx)
{
diff --git a/src/interfaces/libpq/fe-secure-common.c b/src/interfaces/libpq/fe-secure-common.c
index 40203f3..b3f580f 100644
--- a/src/interfaces/libpq/fe-secure-common.c
+++ b/src/interfaces/libpq/fe-secure-common.c
@@ -88,10 +88,17 @@ pq_verify_peer_name_matches_certificate_name(PGconn *conn,
{
char *name;
int result;
- char *host = PQhost(conn);
+ char *host = conn->connhost[conn->whichhost].host;
*store_name = NULL;
+ if (!(host && host[0] != '\0'))
+ {
+ printfPQExpBuffer(&conn->errorMessage,
+ libpq_gettext("host name must be specified\n"));
+ return -1;
+ }
+
/*
* There is no guarantee the string returned from the certificate is
* NULL-terminated, so make a copy that is.
@@ -145,7 +152,7 @@ pq_verify_peer_name_matches_certificate_name(PGconn *conn,
bool
pq_verify_peer_name_matches_certificate(PGconn *conn)
{
- char *host = PQhost(conn);
+ char *host = conn->connhost[conn->whichhost].host;
int rc;
int names_examined = 0;
char *first_name = NULL;