Commit 7c3d99088b for openssl.org

commit 7c3d99088bdf115cd82316a7aa322038882423f2
Author: Paul Dale <paul.dale@oracle.com>
Date:   Mon Nov 23 13:00:30 2026 +1100

    include/internal/safe_math.h: fix unsigned limits for narrow integer types

    Cast the complemented value back to the requested type.  Otherwise,
    integer promotion makes the unsigned char and short limits equal -1.

    Fixes: b037e3637a49 "header: add integer overflow helper functions"
    Assisted-by: ChatGPT:gpt-6-Sol
    Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
    Reviewed-by: Neil Horman <nhorman@openssl.org>
    Merge-date: Tue Nov 24 18:13:17 2026
    Merged-from: https://github.com/openssl/openssl/pull/33917

diff --git a/include/internal/safe_math.h b/include/internal/safe_math.h
index d2702dbb31..73480ba444 100644
--- a/include/internal/safe_math.h
+++ b/include/internal/safe_math.h
@@ -468,7 +468,7 @@
 /* Calculate ranges of types */
 #define OSSL_SAFE_MATH_MAXS(type) ((type)((((type)1 << (sizeof(type) * 8 - 2)) - 1) * 2 + 1))
 #define OSSL_SAFE_MATH_MINS(type) (-OSSL_SAFE_MATH_MAXS(type) - 1)
-#define OSSL_SAFE_MATH_MAXU(type) (~(type)0)
+#define OSSL_SAFE_MATH_MAXU(type) ((type) ~(type)0)

 /*
  * Wrapper macros to create all the functions of a given type