From b0b77118fee59b0db6eb3823b0191d9cd0ef9fc6 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Tue, 19 Oct 2021 19:18:04 +0200 Subject: passt: Address warnings from Clang's scan-build All false positives so far. Signed-off-by: Stefano Brivio --- udp.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'udp.c') diff --git a/udp.c b/udp.c index 5c0e955..0703fc9 100644 --- a/udp.c +++ b/udp.c @@ -461,10 +461,17 @@ int udp_splice_connect(struct ctx *c, int v6, int bound_sock, if (getsockname(s, (struct sockaddr *)&sa, &sl)) goto fail; - if (v6) - ref.udp.port = ntohs(((struct sockaddr_in6 *)&sa)->sin6_port); - else - ref.udp.port = ntohs(((struct sockaddr_in *)&sa)->sin_port); + if (v6) { + struct sockaddr_in6 sa6; + + memcpy(&sa6, &sa, sizeof(sa6)); + ref.udp.port = ntohs(sa6.sin6_port); + } else { + struct sockaddr_in sa4; + + memcpy(&sa4, &sa, sizeof(sa4)); + ref.udp.port = ntohs(sa4.sin_port); + } sp = &udp_splice_map[v6 ? V6 : V4][ref.udp.port]; if (splice == UDP_BACK_TO_INIT) { -- cgit v1.2.3