]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: intops: mask the fail value in array_size_or_fail()
authorWilly Tarreau <w@1wt.eu>
Mon, 25 May 2026 05:23:49 +0000 (07:23 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 25 May 2026 05:33:35 +0000 (07:33 +0200)
Cross-compilation on m68k fails in ssl_sock_resize_passphrase_cache()
where the compiler noticed the SIZE_MAX passed to realloc() in the
error path and complained that it's larger than PTRDIFF_MAX. This can
be disabled with -Walloc-size-larger-than=SIZE_MAX but in practice we
can simply hide the value and keep the warning to detect real failures
elsewhere. Let's pass it through DISGUISE() and also take this
opportunity for doing that inside an unlikely() clause since it's never
supposed to happen.

include/haproxy/intops.h

index e1b637c30d6362fdf098e508023a315a466bb4c1..08a9abc8b8bc4b67fe5e4833ba1ea7ed78e03228 100644 (file)
@@ -121,8 +121,8 @@ static inline size_t array_size_or_fail(size_t m, size_t n)
 {
        size_t size;
 
-       if (mulsz_overflow(m, n, &size))
-               return ~(size_t)0;
+       if (unlikely(mulsz_overflow(m, n, &size)))
+               return DISGUISE(~(size_t)0);
        return size;
 }