diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2021-10-19 19:18:04 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2021-10-20 08:29:30 +0200 |
commit | b0b77118fee59b0db6eb3823b0191d9cd0ef9fc6 (patch) | |
tree | f4494fee397426916a5b7cdaecab9d79232f8e75 /udp.c | |
parent | 1a563a0cbd4926d0dfe9065a4fcd8771c5b292cc (diff) | |
download | passt-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.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -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) { |