mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Merge branch 'development' into dtls
* development:
Fix the fix to ssl_set_psk()
Update Changelog
Finish fixing memleak in ssl_server2 arg parsing
Fix another potential memory leak found by find-mem-leak.cocci.
Add a rule for another type of memory leak to find-mem-leak.cocci.
Fix a potential memory leak found by find-mem-leak.cocci.
Add a semantic patch to find potential memory leaks.
Fix whitespace of 369e6c20
.
Apply the semantic patch rm-malloc-cast.cocci.
Add a semantic patch to remove casts of malloc.
This commit is contained in:
@ -5463,21 +5463,23 @@ int ssl_set_psk( ssl_context *ssl, const unsigned char *psk, size_t psk_len,
|
||||
if( psk_len > POLARSSL_PSK_MAX_LEN )
|
||||
return( POLARSSL_ERR_SSL_BAD_INPUT_DATA );
|
||||
|
||||
if( ssl->psk != NULL )
|
||||
if( ssl->psk != NULL || ssl->psk_identity != NULL )
|
||||
{
|
||||
polarssl_free( ssl->psk );
|
||||
polarssl_free( ssl->psk_identity );
|
||||
}
|
||||
|
||||
if( ( ssl->psk = polarssl_malloc( psk_len ) ) == NULL ||
|
||||
( ssl->psk_identity = polarssl_malloc( psk_identity_len ) ) == NULL )
|
||||
{
|
||||
polarssl_free( ssl->psk );
|
||||
ssl->psk = NULL;
|
||||
return( POLARSSL_ERR_SSL_MALLOC_FAILED );
|
||||
}
|
||||
|
||||
ssl->psk_len = psk_len;
|
||||
ssl->psk_identity_len = psk_identity_len;
|
||||
|
||||
ssl->psk = polarssl_malloc( ssl->psk_len );
|
||||
ssl->psk_identity = polarssl_malloc( ssl->psk_identity_len );
|
||||
|
||||
if( ssl->psk == NULL || ssl->psk_identity == NULL )
|
||||
return( POLARSSL_ERR_SSL_MALLOC_FAILED );
|
||||
|
||||
memcpy( ssl->psk, psk, ssl->psk_len );
|
||||
memcpy( ssl->psk_identity, psk_identity, ssl->psk_identity_len );
|
||||
|
||||
|
Reference in New Issue
Block a user