Skip to content

Commit ed51bd4

Browse files
committed
Use only addr_cur when reporting connection failures in libpq.
1 parent 4f6deef commit ed51bd4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/interfaces/libpq/fe-connect.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -989,17 +989,16 @@ connectFailureMessage(PGconn *conn, int errorno)
989989
{
990990
char host_addr[NI_MAXHOST];
991991
bool display_host_addr;
992-
struct sockaddr_in *host_addr_struct = (struct sockaddr_in *)
993-
&conn->raddr.addr;
994992

995993
/*
996994
* Optionally display the network address with the hostname.
997995
* This is useful to distinguish between IPv4 and IPv6 connections.
998996
*/
999997
if (conn->pghostaddr != NULL)
1000998
strlcpy(host_addr, conn->pghostaddr, NI_MAXHOST);
1001-
else if (inet_net_ntop(conn->addr_cur->ai_family, &host_addr_struct->sin_addr,
1002-
host_addr_struct->sin_family == AF_INET ? 32 : 128,
999+
else if (inet_net_ntop(conn->addr_cur->ai_family,
1000+
&conn->addr_cur->ai_addr,
1001+
conn->addr_cur->ai_family == AF_INET ? 32 : 128,
10031002
host_addr, sizeof(host_addr)) == NULL)
10041003
strcpy(host_addr, "???");
10051004

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy