mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-02-02 18:51:05 +00:00
Fix references to non-standard SIZE_T_MAX
Turns out C99 doesn't define SIZE_T_MAX, so let's not use it.
This commit is contained in:
parent
d64f1ad98b
commit
42571ddb4e
|
@ -25,7 +25,6 @@
|
|||
#define POLARSSL_BASE64_H
|
||||
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#define POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL -0x002A /**< Output buffer too small. */
|
||||
#define POLARSSL_ERR_BASE64_INVALID_CHARACTER -0x002C /**< Invalid character in input. */
|
||||
|
|
|
@ -61,6 +61,8 @@ static const unsigned char base64_dec_map[128] =
|
|||
49, 50, 51, 127, 127, 127, 127, 127
|
||||
};
|
||||
|
||||
#define BASE64_SIZE_T_MAX ( (size_t) -1 ) /* SIZE_T_MAX is not standard */
|
||||
|
||||
/*
|
||||
* Encode a buffer into base64 format
|
||||
*/
|
||||
|
@ -79,9 +81,9 @@ int base64_encode( unsigned char *dst, size_t *dlen,
|
|||
|
||||
n = slen / 3 + ( slen % 3 != 0 );
|
||||
|
||||
if( n > ( SIZE_T_MAX - 1 ) / 4 )
|
||||
if( n > ( BASE64_SIZE_T_MAX - 1 ) / 4 )
|
||||
{
|
||||
*dlen = SIZE_T_MAX;
|
||||
*dlen = BASE64_SIZE_T_MAX;
|
||||
return( POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL );
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include "polarssl/bignum.h"
|
||||
#include "polarssl/bn_mul.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Implementation that should never be optimized out by the compiler */
|
||||
|
@ -46,6 +45,8 @@ static void polarssl_zeroize( void *v, size_t n ) {
|
|||
#define biL (ciL << 3) /* bits in limb */
|
||||
#define biH (ciL << 2) /* half limb size */
|
||||
|
||||
#define MPI_SIZE_T_MAX ( (size_t) -1 ) /* SIZE_T_MAX is not standard */
|
||||
|
||||
/*
|
||||
* Convert between bits/chars and number of limbs
|
||||
* Divide first in order to avoid potential overflows
|
||||
|
@ -289,7 +290,7 @@ int mpi_read_string( mpi *X, int radix, const char *s )
|
|||
|
||||
if( radix == 16 )
|
||||
{
|
||||
if( slen > SIZE_T_MAX >> 2 )
|
||||
if( slen > MPI_SIZE_T_MAX >> 2 )
|
||||
return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
|
||||
|
||||
n = BITS_TO_LIMBS( slen << 2 );
|
||||
|
|
Loading…
Reference in a new issue