From 2b793d94ca353ac3071b5d9a75e73b64cc0c76ca Mon Sep 17 00:00:00 2001 From: David Gibson Date: Fri, 4 Nov 2022 14:10:32 +1100 Subject: Correct some missing endian conversions of IPv4 addresses The INADDR_LOOPBACK constant is in host endianness, and similarly the IN_MULTICAST macro expects a host endian address. However, there are some places in passt where we use those with network endian values. This means that passt will incorrectly allow you to set 127.0.0.1 or a multicast address as the guest address or DNS forwarding address. Add the necessary conversions to correct this. INADDR_ANY and INADDR_BROADCAST logically behave the same way, although because they're palindromes it doesn't have an effect in practice. Change them to be logically correct while we're there, though. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- icmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'icmp.c') diff --git a/icmp.c b/icmp.c index 4ee847f..d388815 100644 --- a/icmp.c +++ b/icmp.c @@ -154,7 +154,7 @@ int icmp_tap_handler(const struct ctx *c, int af, const void *addr, union icmp_epoll_ref iref = { .icmp.v6 = 0 }; struct sockaddr_in sa = { .sin_family = AF_INET, - .sin_addr = { .s_addr = INADDR_ANY }, + .sin_addr = { .s_addr = htonl(INADDR_ANY) }, }; struct icmphdr *ih; int id, s; -- cgit v1.2.3