Merge pull request #3578 from gilles-peskine-arm/md_setup-leak-development
Fix memory leak in mbedtls_md_setup with HMAC
This commit is contained in:
commit
1a6af8489e
3
ChangeLog.d/md_setup-leak.txt
Normal file
3
ChangeLog.d/md_setup-leak.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Bugfix
|
||||||
|
* Fix a memory leak in mbedtls_md_setup() when using HMAC under low memory
|
||||||
|
conditions. Reported and fix suggested by Guido Vranken in #3486.
|
@ -411,6 +411,10 @@ int mbedtls_md_setup( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_inf
|
|||||||
if( md_info == NULL || ctx == NULL )
|
if( md_info == NULL || ctx == NULL )
|
||||||
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
|
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
|
||||||
|
|
||||||
|
ctx->md_info = md_info;
|
||||||
|
ctx->md_ctx = NULL;
|
||||||
|
ctx->hmac_ctx = NULL;
|
||||||
|
|
||||||
switch( md_info->type )
|
switch( md_info->type )
|
||||||
{
|
{
|
||||||
#if defined(MBEDTLS_MD2_C)
|
#if defined(MBEDTLS_MD2_C)
|
||||||
@ -466,8 +470,6 @@ int mbedtls_md_setup( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_inf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->md_info = md_info;
|
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
#undef ALLOC
|
#undef ALLOC
|
||||||
|
Loading…
Reference in New Issue
Block a user