Skip to content

Commit

Permalink
fix: potential undefined behavior in mbedtls_mpi_sub_abs()
Browse files Browse the repository at this point in the history
  • Loading branch information
wendal committed Oct 29, 2023
1 parent 08645ca commit 467621a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion components/mbedtls/library/bignum.c
Expand Up @@ -1237,7 +1237,7 @@ int mbedtls_mpi_sub_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi
/* Set the high limbs of X to match A. Don't touch the lower limbs
* because X might be aliased to B, and we must not overwrite the
* significant digits of B. */
if( A->n > n )
if( A->n > n && A != X)
memcpy( X->p + n, A->p + n, ( A->n - n ) * ciL );
if( X->n > A->n )
memset( X->p + A->n, 0, ( X->n - A->n ) * ciL );
Expand Down

0 comments on commit 467621a

Please sign in to comment.