Skip to content

Commit 28b35c0

Browse files
committed
Merge branch 'mbedtls-2.1'
Merge of fix for memory leak in RSA-SSA signing - Mbed-TLS#372
2 parents 976794a + 318daf0 commit 28b35c0

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

ChangeLog

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ Bugfix
1414
* Fix bug in certificate validation that caused valid chains to be rejected
1515
when the first intermediate certificate has pathLenConstraint=0. Found by
1616
Nicholas Wilson. Introduced in mbed TLS 2.1.4. #280
17+
* Removed potential leak in mbedtls_rsa_rsassa_pkcs1_v15_sign(), found by
18+
JayaraghavendranK. #372
1719

18-
Changes
20+
Change
1921
* To avoid dropping an entire DTLS datagram if a single record in a datagram
2022
is invalid, we now only drop the record and look at subsequent records (if
2123
any are present) in the same datagram to avoid interoperability issues.

library/rsa.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,9 +1086,15 @@ int mbedtls_rsa_rsassa_pkcs1_v15_sign( mbedtls_rsa_context *ctx,
10861086
* temporary buffer and check it before returning it.
10871087
*/
10881088
sig_try = mbedtls_calloc( 1, ctx->len );
1089+
if( sig_try == NULL )
1090+
return( MBEDTLS_ERR_MPI_ALLOC_FAILED );
1091+
10891092
verif = mbedtls_calloc( 1, ctx->len );
1090-
if( sig_try == NULL || verif == NULL )
1093+
if( verif == NULL )
1094+
{
1095+
mbedtls_free( sig_try );
10911096
return( MBEDTLS_ERR_MPI_ALLOC_FAILED );
1097+
}
10921098

10931099
MBEDTLS_MPI_CHK( mbedtls_rsa_private( ctx, f_rng, p_rng, sig, sig_try ) );
10941100
MBEDTLS_MPI_CHK( mbedtls_rsa_public( ctx, sig_try, verif ) );

0 commit comments

Comments
 (0)