Azure-Samples / Azure-Samples/iot-middleware-freertos-samples
Uninitialized memory in TLS_Socket_Connect will cause random free of memory in mbedlts context
- Dominant language
- CMake
- Stars
- 88
- Forks
- 54
- PR merge metrics
- No merged PRs in 30d
Description
In the **transport_tls_socket_using_mbedtls.c** in the function **TLS_Socket_Connect** we allocate memory for the ssl context.
if( ( pxSSLContext = pvPortMalloc( sizeof( MbedSSLContext_t ) ) ) == NULL )
if the pxSSLContext memory is allocated we start doing the TLS operations.
If any of the TLS operation fails, we do the cleanup which involves **sslContextFree( pxSSLContext )**;
The check for what memory to free in the sslContext attributes is done with comparison with 0.
But if the memory is not initialized before, random free can appear as the struct can hold already some data
My suggestion is if the memory has been allocated, do a **memset(pxSSLContext , 0, sizeof( MbedSSLContext_t ))**
Contributor guide
Assessment
This issue has not been assessed yet.