aboutgitcodebugslistschat
path: root/icmp.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2022-11-04 14:10:32 +1100
committerStefano Brivio <sbrivio@redhat.com>2022-11-04 12:03:58 +0100
commit2b793d94ca353ac3071b5d9a75e73b64cc0c76ca (patch)
treee9ae3721c95cbb28673dca6e6cfa7d6aa7ec1f67 /icmp.c
parent40fc9e6e7b46819bfa275abf8e0f0e5b6ae7316b (diff)
downloadpasst-2b793d94ca353ac3071b5d9a75e73b64cc0c76ca.tar
passt-2b793d94ca353ac3071b5d9a75e73b64cc0c76ca.tar.gz
passt-2b793d94ca353ac3071b5d9a75e73b64cc0c76ca.tar.bz2
passt-2b793d94ca353ac3071b5d9a75e73b64cc0c76ca.tar.lz
passt-2b793d94ca353ac3071b5d9a75e73b64cc0c76ca.tar.xz
passt-2b793d94ca353ac3071b5d9a75e73b64cc0c76ca.tar.zst
passt-2b793d94ca353ac3071b5d9a75e73b64cc0c76ca.zip
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 <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'icmp.c')
-rw-r--r--icmp.c2
1 files changed, 1 insertions, 1 deletions
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;