From 745fa3816979c535b6b046fbc6710a969360ac02 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Wed, 28 Feb 2024 16:39:28 +1100 Subject: 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 Signed-off-by: Stefano Brivio --- udp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'udp.c') 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)) -- cgit v1.2.3