aboutgitcodebugslistschat
path: root/udp.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2024-02-28 16:39:28 +1100
committerStefano Brivio <sbrivio@redhat.com>2024-02-29 05:41:03 +0100
commit745fa3816979c535b6b046fbc6710a969360ac02 (patch)
tree2da4b87401c86b49aa9626603f0a0b0e0a8ab3e3 /udp.c
parentdeea5a84373169a2886bbeaf674a4ebb864ba2ac (diff)
downloadpasst-745fa3816979c535b6b046fbc6710a969360ac02.tar
passt-745fa3816979c535b6b046fbc6710a969360ac02.tar.gz
passt-745fa3816979c535b6b046fbc6710a969360ac02.tar.bz2
passt-745fa3816979c535b6b046fbc6710a969360ac02.tar.lz
passt-745fa3816979c535b6b046fbc6710a969360ac02.tar.xz
passt-745fa3816979c535b6b046fbc6710a969360ac02.tar.zst
passt-745fa3816979c535b6b046fbc6710a969360ac02.zip
udp: Fix incorrect usage of IPv6 state in IPv4 path
When forwarding IPv4 packets in udp_tap_handler(), we incorrectly use an IPv6 address test on our IPv4 address (which could cause an out of bounds access), and possibly set our bind interface to the IPv6 interface based on it. Adjust to correctly look at the IPv4 address and IPv4 interface. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'udp.c')
-rw-r--r--udp.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/udp.c b/udp.c
index 561ba60..d55a682 100644
--- a/udp.c
+++ b/udp.c
@@ -875,8 +875,8 @@ int udp_tap_handler(struct ctx *c, uint8_t pif,
};
const char *bind_if = NULL;
- if (!IN6_IS_ADDR_LOOPBACK(&s_in.sin_addr))
- bind_if = c->ip6.ifname_out;
+ if (!IN4_IS_ADDR_LOOPBACK(&s_in.sin_addr))
+ bind_if = c->ip4.ifname_out;
if (!IN4_IS_ADDR_UNSPECIFIED(&c->ip4.addr_out) &&
!IN4_IS_ADDR_LOOPBACK(&s_in.sin_addr))