Index | Thread | Search

From:
Florian Obser <florian@openbsd.org>
Subject:
netstat(1): get rid of inet_aton
To:
tech <tech@openbsd.org>
Date:
Sun, 11 Aug 2024 18:00:03 +0200

Download raw body.

Thread
localhost is just a weird spelling for 127.0.0.1...

I'm not entirely sure how to tickle this code though.

OK?

diff --git inet.c inet.c
index 88d37be055e..a6c0a4b8282 100644
--- inet.c
+++ inet.c
@@ -813,7 +813,6 @@ static char *
 getrpcportnam(in_port_t port, int proto)
 {
 	struct sockaddr_in server_addr;
-	struct hostent *hp;
 	static struct pmaplist *head;
 	int socket = RPC_ANYSOCK;
 	struct timeval minutetimeout;
@@ -828,11 +827,7 @@ getrpcportnam(in_port_t port, int proto)
 		first = 1;
 		memset(&server_addr, 0, sizeof server_addr);
 		server_addr.sin_family = AF_INET;
-		if ((hp = gethostbyname("localhost")) != NULL)
-			memmove((caddr_t)&server_addr.sin_addr, hp->h_addr,
-			    hp->h_length);
-		else
-			(void) inet_aton("0.0.0.0", &server_addr.sin_addr);
+		(void) inet_pton(AF_INET, "127.0.0.1", &server_addr.sin_addr);
 
 		minutetimeout.tv_sec = 60;
 		minutetimeout.tv_usec = 0;


-- 
In my defence, I have been left unsupervised.