[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug #691306: iptables add 4 rules instead just one in kernel INPUT chain



Hi libc folks,

iptables --insert --source localhost ...
is currently creating duplicate entries.

I believe this is because of a problem in gethostbyname("localhost") that
returns duplicate answers.

Attached is a tiny test case.

./main
127.0.0.1
120.0.0.1

If I comment out "::1 localhost" in my /etc/hosts file, I only get one answer:

./main
127.0.0.1

Has anything like that bent repported/fixed recently?
#include <stdio.h>
#include <netdb.h>
#include <arpa/inet.h>

int main() {
	
	struct hostent *host;
	struct in_addr **addr;

	host = gethostbyname("localhost");

	if (!host
	 || host->h_addrtype != AF_INET
	 || host->h_length != sizeof(struct in_addr))
		return -1;

	for(addr=host->h_addr_list; *addr; ++addr)
		puts(inet_ntoa(**addr));

	return 0;
}

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: