Skip to content

Commit f2eba41

Browse files
committed
Use conn->raddr consistently for non-connect libpq error reporting.
1 parent bad8277 commit f2eba41

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/interfaces/libpq/fe-connect.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -989,16 +989,18 @@ 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;
992994

993995
/*
994996
* Optionally display the network address with the hostname.
995997
* This is useful to distinguish between IPv4 and IPv6 connections.
996998
*/
997999
if (conn->pghostaddr != NULL)
9981000
strlcpy(host_addr, conn->pghostaddr, NI_MAXHOST);
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,
1001+
else if (inet_net_ntop(host_addr_struct->sin_family,
1002+
&host_addr_struct->sin_addr.s_addr,
1003+
host_addr_struct->sin_family == AF_INET ? 32 : 128,
10021004
host_addr, sizeof(host_addr)) == NULL)
10031005
strcpy(host_addr, "???");
10041006

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