Use mbedtls_{calloc|free}() in SSL unit test suite
@@ -39,8 +39,8 @@ static int build_transforms( mbedtls_ssl_transform *t_in,
/* Pick keys */
keylen = cipher_info->key_bitlen / 8;
- CHK( ( key0 = malloc( keylen ) ) != NULL );
- CHK( ( key1 = malloc( keylen ) ) != NULL );
+ CHK( ( key0 = mbedtls_calloc( 1, keylen ) ) != NULL );
+ CHK( ( key1 = mbedtls_calloc( 1, keylen ) ) != NULL );
memset( key0, 0x1, keylen );
memset( key1, 0x2, keylen );
@@ -87,8 +87,8 @@ static int build_transforms( mbedtls_ssl_transform *t_in,
/* Pick hash keys */
maclen = mbedtls_md_get_size( md_info );
- CHK( ( md0 = malloc( maclen ) ) != NULL );
- CHK( ( md1 = malloc( maclen ) ) != NULL );
+ CHK( ( md0 = mbedtls_calloc( 1, maclen ) ) != NULL );
+ CHK( ( md1 = mbedtls_calloc( 1, maclen ) ) != NULL );
memset( md0, 0x5, maclen );
memset( md1, 0x6, maclen );
@@ -118,8 +118,8 @@ static int build_transforms( mbedtls_ssl_transform *t_in,
}
#endif
- free( md0 );
- free( md1 );
+ mbedtls_free( md0 );
+ mbedtls_free( md1 );
}
#else
((void) hash_id);
@@ -225,8 +225,8 @@ static int build_transforms( mbedtls_ssl_transform *t_in,
cleanup:
- free( key0 );
- free( key1 );
+ mbedtls_free( key0 );
+ mbedtls_free( key1 );
return( 0 );
}
@@ -308,7 +308,7 @@ void ssl_crypt_record( int cipher_type, int hash_id,
TEST_ASSERT( build_transforms( &t0, &t1, cipher_type, hash_id,
etm, tag_mode, ver ) == 0 );
- TEST_ASSERT( ( buf = malloc( buflen ) ) != NULL );
+ TEST_ASSERT( ( buf = mbedtls_calloc( 1, buflen ) ) != NULL );
while( num_records-- > 0 )
{
@@ -385,7 +385,7 @@ exit:
mbedtls_ssl_transform_free( &t0 );
mbedtls_ssl_transform_free( &t1 );
- free( buf );
+ mbedtls_free( buf );
}
/* END_CASE */
@@ -437,7 +437,7 @@ void ssl_crypt_record_small( int cipher_type, int hash_id,
TEST_ASSERT( build_transforms( &t0, &t1, cipher_type, hash_id,
etm, tag_mode, ver ) == 0 );
- TEST_ASSERT( ( buf = malloc( buflen ) ) != NULL );
+ TEST_ASSERT( ( buf = mbedtls_calloc( 1, buflen ) ) != NULL );
for( mode=1; mode <= 3; mode++ )
{
@@ -533,6 +533,6 @@ exit:
mbedtls_ssl_transform_free( &t0 );
mbedtls_ssl_transform_free( &t1 );
- free( buf );
+ mbedtls_free( buf );
}
/* END_CASE */
