aboutgitcodebugslistschat
path: root/udp.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2021-10-19 19:18:04 +0200
committerStefano Brivio <sbrivio@redhat.com>2021-10-20 08:29:30 +0200
commitb0b77118fee59b0db6eb3823b0191d9cd0ef9fc6 (patch)
treef4494fee397426916a5b7cdaecab9d79232f8e75 /udp.c
parent1a563a0cbd4926d0dfe9065a4fcd8771c5b292cc (diff)
downloadpasst-b0b77118fee59b0db6eb3823b0191d9cd0ef9fc6.tar
passt-b0b77118fee59b0db6eb3823b0191d9cd0ef9fc6.tar.gz
passt-b0b77118fee59b0db6eb3823b0191d9cd0ef9fc6.tar.bz2
passt-b0b77118fee59b0db6eb3823b0191d9cd0ef9fc6.tar.lz
passt-b0b77118fee59b0db6eb3823b0191d9cd0ef9fc6.tar.xz
passt-b0b77118fee59b0db6eb3823b0191d9cd0ef9fc6.tar.zst
passt-b0b77118fee59b0db6eb3823b0191d9cd0ef9fc6.zip
passt: Address warnings from Clang's scan-build
All false positives so far. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'udp.c')
-rw-r--r--udp.c15
1 files changed, 11 insertions, 4 deletions
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) {