diff --git a/library/base64.c b/library/base64.c index 4170610642..3eb9e7cc55 100644 --- a/library/base64.c +++ b/library/base64.c @@ -17,6 +17,8 @@ * limitations under the License. */ +#include + #include "common.h" #if defined(MBEDTLS_BASE64_C) @@ -31,8 +33,6 @@ #include "mbedtls/platform.h" #endif /* MBEDTLS_SELF_TEST */ -#define BASE64_SIZE_T_MAX ((size_t) -1) /* SIZE_T_MAX is not standard */ - /* * Encode a buffer into base64 format */ @@ -50,8 +50,8 @@ int mbedtls_base64_encode(unsigned char *dst, size_t dlen, size_t *olen, n = slen / 3 + (slen % 3 != 0); - if (n > (BASE64_SIZE_T_MAX - 1) / 4) { - *olen = BASE64_SIZE_T_MAX; + if (n > (SIZE_MAX - 1) / 4) { + *olen = SIZE_MAX; return MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL; } diff --git a/library/bignum.c b/library/bignum.c index e686a1ba23..36effaf8da 100644 --- a/library/bignum.c +++ b/library/bignum.c @@ -54,8 +54,6 @@ #define MPI_VALIDATE(cond) \ MBEDTLS_INTERNAL_VALIDATE(cond) -#define MPI_SIZE_T_MAX ((size_t) -1) /* SIZE_T_MAX is not standard */ - /* Implementation that should never be optimized out by the compiler */ static void mbedtls_mpi_zeroize(mbedtls_mpi_uint *v, size_t n) { @@ -416,7 +414,7 @@ int mbedtls_mpi_read_string(mbedtls_mpi *X, int radix, const char *s) slen = strlen(s); if (radix == 16) { - if (slen > MPI_SIZE_T_MAX >> 2) { + if (slen > SIZE_MAX >> 2) { return MBEDTLS_ERR_MPI_BAD_INPUT_DATA; }