diff options
author | Laurent Vivier <lvivier@redhat.com> | 2025-05-13 11:41:01 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2025-05-14 17:51:35 +0200 |
commit | 0f7bf10b0a5542690dc6c75e4b56a6030ca8a663 (patch) | |
tree | 7065e41b0ca8aac21de09bf0765c728a88521998 | |
parent | a6b9832e495be636bcccf25e0aebdeb564addf06 (diff) | |
download | passt-0f7bf10b0a5542690dc6c75e4b56a6030ca8a663.tar passt-0f7bf10b0a5542690dc6c75e4b56a6030ca8a663.tar.gz passt-0f7bf10b0a5542690dc6c75e4b56a6030ca8a663.tar.bz2 passt-0f7bf10b0a5542690dc6c75e4b56a6030ca8a663.tar.lz passt-0f7bf10b0a5542690dc6c75e4b56a6030ca8a663.tar.xz passt-0f7bf10b0a5542690dc6c75e4b56a6030ca8a663.tar.zst passt-0f7bf10b0a5542690dc6c75e4b56a6030ca8a663.zip |
ndp: Fix Clang analyzer warning (clang-analyzer-security.PointerSub)
Addresses Clang warning: "Subtraction of two pointers that do not
point into the same array is undefined behavior" for the line:
`ndp_send(c, dst, &ra, ptr - (unsigned char *)&ra);`
Here, `ptr` is `&ra.var[0]`. The subtraction calculates the offset
of `var[0]` within the `struct ra_options ra`. Since `ptr` points
inside `ra`, this pointer arithmetic is well-defined for
calculating the size of the data to send, even if `ptr` and `&ra`
are not strictly considered part of the same "array" by the analyzer.
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r-- | ndp.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -328,6 +328,7 @@ static void ndp_ra(const struct ctx *c, const struct in6_addr *dst) memcpy(&ra.source_ll.mac, c->our_tap_mac, ETH_ALEN); + /* NOLINTNEXTLINE(clang-analyzer-security.PointerSub) */ ndp_send(c, dst, &ra, ptr - (unsigned char *)&ra); } |