Skip to content

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

@SavaAlexandru

Description

@SavaAlexandru

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions