Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uninitialized memory in TLS_Socket_Connect will cause random free of memory in mbedlts context #385

Open
SavaAlexandru opened this issue Dec 20, 2023 · 0 comments

Comments

@SavaAlexandru
Copy link

SavaAlexandru commented Dec 20, 2023

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 ))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant