Skip to content

Commit

Permalink
Merge pull request Mbed-TLS#3002 from gilles-peskine-arm/coverity-202…
Browse files Browse the repository at this point in the history
…00115-2.7 into mbedtls-2.7
  • Loading branch information
yanesca committed Jan 29, 2020
2 parents 130e136 + 16ba09c commit a67508e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ mbed TLS ChangeLog (Sorted per branch, date)
Bugfix
* Allow loading symlinked certificates. Fixes #3005. Reported and fixed
by Jonathan Bennett <[email protected]> via #3008.
* Fix an unchecked call to mbedtls_md() in the x509write module.

= mbed TLS 2.7.13 branch released 2020-01-15

Expand Down
14 changes: 4 additions & 10 deletions library/cipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *i

*olen = 0;
block_size = mbedtls_cipher_get_block_size( ctx );
if ( 0 == block_size )
{
return( MBEDTLS_ERR_CIPHER_INVALID_CONTEXT );
}

if( ctx->cipher_info->mode == MBEDTLS_MODE_ECB )
{
Expand All @@ -308,11 +312,6 @@ int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *i
}
#endif

if ( 0 == block_size )
{
return MBEDTLS_ERR_CIPHER_INVALID_CONTEXT;
}

if( input == output &&
( ctx->unprocessed_len != 0 || ilen % block_size ) )
{
Expand Down Expand Up @@ -371,11 +370,6 @@ int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *i
*/
if( 0 != ilen )
{
if( 0 == block_size )
{
return MBEDTLS_ERR_CIPHER_INVALID_CONTEXT;
}

/* Encryption: only cache partial blocks
* Decryption w/ padding: always keep at least one whole block
* Decryption w/o padding: only cache partial blocks
Expand Down
4 changes: 3 additions & 1 deletion library/x509write_csr.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,9 @@ int mbedtls_x509write_csr_der( mbedtls_x509write_csr *ctx, unsigned char *buf, s
/*
* Prepare signature
*/
mbedtls_md( mbedtls_md_info_from_type( ctx->md_alg ), c, len, hash );
ret = mbedtls_md( mbedtls_md_info_from_type( ctx->md_alg ), c, len, hash );
if( ret != 0 )
return( ret );

if( ( ret = mbedtls_pk_sign( ctx->key, ctx->md_alg, hash, 0, sig, &sig_len,
f_rng, p_rng ) ) != 0 )
Expand Down
4 changes: 2 additions & 2 deletions tests/suites/test_suite_mpi.function
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@ void mbedtls_mpi_lt_mpi_ct( int size_X, char * input_X,
TEST_ASSERT( mbedtls_mpi_read_string( &X, 16, input_X ) == 0 );
TEST_ASSERT( mbedtls_mpi_read_string( &Y, 16, input_Y ) == 0 );

mbedtls_mpi_grow( &X, size_X );
mbedtls_mpi_grow( &Y, size_Y );
TEST_ASSERT( mbedtls_mpi_grow( &X, size_X ) == 0 );
TEST_ASSERT( mbedtls_mpi_grow( &Y, size_Y ) == 0 );

TEST_ASSERT( mbedtls_mpi_lt_mpi_ct( &X, &Y, &ret ) == input_err );
if( input_err == 0 )
Expand Down

0 comments on commit a67508e

Please sign in to comment.