From: Richard Levitte Date: Fri, 18 Jun 2021 08:32:32 +0000 (+0200) Subject: Fix definition of ossl_intmax_t and ossl_uintmax_t X-Git-Tag: openssl-3.0.0-beta2~244 X-Git-Url: https://git.openssl.org/?p=openssl.git;a=commitdiff_plain;h=08ee6addf7343e7523db47dcc7e84e1670d52e15 Fix definition of ossl_intmax_t and ossl_uintmax_t These definitions were located away from our definitions of other sized int and uint types. Also, the fallback typedef wasn't quite correct, and this changes it to be aliases for int64_t and uint64_t, since those are the largest integers we commonly handle. We also make sure to define corresponding numbers: OSSL_INTMAX_MIN, OSSL_INTMAX_MAX and OSSL_UINTMAX_MAX Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/15825) --- diff --git a/include/internal/numbers.h b/include/internal/numbers.h index ac801364d9..4f4d3306d5 100644 --- a/include/internal/numbers.h +++ b/include/internal/numbers.h @@ -75,5 +75,11 @@ typedef __uint128_t uint128_t; # define SIZE_MAX __MAXUINT__(size_t) # endif +# ifndef OSSL_INTMAX_MAX +# define OSSL_INTMAX_MIN __MININT__(ossl_intmax_t) +# define OSSL_INTMAX_MAX __MAXINT__(ossl_intmax_t) +# define OSSL_UINTMAX_MAX __MAXUINT__(ossl_uintmax_t) +# endif + #endif diff --git a/include/openssl/e_os2.h b/include/openssl/e_os2.h index 49e6dad73c..6728909271 100644 --- a/include/openssl/e_os2.h +++ b/include/openssl/e_os2.h @@ -252,6 +252,15 @@ typedef unsigned __int64 uint64_t; # include # undef OPENSSL_NO_STDINT_H # endif +# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && \ + defined(INTMAX_MAX) && defined(UINTMAX_MAX) +typedef intmax_t ossl_intmax_t; +typedef uintmax_t ossl_uintmax_t; +# else +/* Fall back to the largest we know we require and can handle */ +typedef int64_t ossl_intmax_t; +typedef uint64_t ossl_uintmax_t; +# endif /* ossl_inline: portable inline definition usable in public headers */ # if !defined(inline) && !defined(__cplusplus) diff --git a/include/openssl/types.h b/include/openssl/types.h index bf5846db05..de9f166524 100644 --- a/include/openssl/types.h +++ b/include/openssl/types.h @@ -229,21 +229,6 @@ typedef struct ossl_decoder_ctx_st OSSL_DECODER_CTX; typedef struct ossl_self_test_st OSSL_SELF_TEST; -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && \ - defined(INTMAX_MAX) && defined(UINTMAX_MAX) -typedef intmax_t ossl_intmax_t; -typedef uintmax_t ossl_uintmax_t; -#else -/* - * Not long long, because the C-library can only be expected to provide - * strtoll(), strtoull() at the same time as intmax_t and strtoimax(), - * strtoumax(). Since we use these for parsing arguments, we need the - * conversion functions, not just the sizes. - */ -typedef long ossl_intmax_t; -typedef unsigned long ossl_uintmax_t; -#endif - #ifdef __cplusplus } #endif