mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-04-29 23:36:26 +00:00
mpi_copy: make the 0 case slightly more robust
If Y was constructed through functions in this module, then Y->n == 0 iff Y->p == NULL. However we do not prevent filling mpi structures manually, and zero may be represented with n=0 and p a valid pointer. Most of the code can cope with such a representation, but for the source of mbedtls_mpi_copy, this would cause an integer underflow. Changing the test for zero from Y->p==NULL to Y->n==0 causes this case to work at no extra cost.
This commit is contained in:
parent
84b8e25426
commit
2aeab87cf7
|
@ -190,7 +190,7 @@ int mbedtls_mpi_copy( mbedtls_mpi *X, const mbedtls_mpi *Y )
|
||||||
if( X == Y )
|
if( X == Y )
|
||||||
return( 0 );
|
return( 0 );
|
||||||
|
|
||||||
if( Y->p == NULL )
|
if( Y->n == 0 )
|
||||||
{
|
{
|
||||||
mbedtls_mpi_free( X );
|
mbedtls_mpi_free( X );
|
||||||
return( 0 );
|
return( 0 );
|
||||||
|
|
Loading…
Reference in a new issue