mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-25 17:25:37 +01:00
Fix parameter validation for mbedtls_mpi_lsb()
The MPI_VALIDATE_RET() macro cannot be used for parameter validation of mbedtls_mpi_lsb() because this function returns a size_t. Use the underlying MBEDTLS_INTERNAL_VALIDATE_RET() insteaed, returning 0 on failure. Also, add a test for this behaviour.
This commit is contained in:
parent
8ce11a323e
commit
f25ee7f79d
@ -380,7 +380,7 @@ cleanup:
|
|||||||
size_t mbedtls_mpi_lsb( const mbedtls_mpi *X )
|
size_t mbedtls_mpi_lsb( const mbedtls_mpi *X )
|
||||||
{
|
{
|
||||||
size_t i, j, count = 0;
|
size_t i, j, count = 0;
|
||||||
MPI_VALIDATE_RET( X != NULL );
|
MBEDTLS_INTERNAL_VALIDATE_RET( X != NULL, 0 );
|
||||||
|
|
||||||
for( i = 0; i < X->n; i++ )
|
for( i = 0; i < X->n; i++ )
|
||||||
for( j = 0; j < biL; j++, count++ )
|
for( j = 0; j < biL; j++, count++ )
|
||||||
|
@ -216,6 +216,8 @@ void mpi_invalid_param( )
|
|||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||||
mbedtls_mpi_div_int( &X, &X, NULL, 42 ) );
|
mbedtls_mpi_div_int( &X, &X, NULL, 42 ) );
|
||||||
|
|
||||||
|
TEST_INVALID_PARAM_RET( 0, mbedtls_mpi_lsb( NULL ) );
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||||
mbedtls_mpi_mod_mpi( NULL, &X, &X ) );
|
mbedtls_mpi_mod_mpi( NULL, &X, &X ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||||
|
Loading…
Reference in New Issue
Block a user