Skip asn1 zeroize if freeing shallow pointers

This skips zeroizing additional pointers to data.
(Note: actual sensitive data should still be zeroized when freed.)

Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
This commit is contained in:
Glenn Strauss 2022-07-01 13:22:45 -04:00
parent a4b4041219
commit 7db3124c00

View file

@ -314,7 +314,6 @@ void mbedtls_asn1_sequence_free( mbedtls_asn1_sequence *seq )
while( seq != NULL ) while( seq != NULL )
{ {
mbedtls_asn1_sequence *next = seq->next; mbedtls_asn1_sequence *next = seq->next;
mbedtls_platform_zeroize( seq, sizeof( *seq ) );
mbedtls_free( seq ); mbedtls_free( seq );
seq = next; seq = next;
} }
@ -450,7 +449,8 @@ void mbedtls_asn1_free_named_data_list( mbedtls_asn1_named_data **head )
while( ( cur = *head ) != NULL ) while( ( cur = *head ) != NULL )
{ {
*head = cur->next; *head = cur->next;
mbedtls_asn1_free_named_data( cur ); mbedtls_free( cur->oid.p );
mbedtls_free( cur->val.p );
mbedtls_free( cur ); mbedtls_free( cur );
} }
} }
@ -460,7 +460,6 @@ void mbedtls_asn1_free_named_data_list_shallow( mbedtls_asn1_named_data *name )
for( mbedtls_asn1_named_data *next; name != NULL; name = next ) for( mbedtls_asn1_named_data *next; name != NULL; name = next )
{ {
next = name->next; next = name->next;
mbedtls_platform_zeroize( name, sizeof( *name ) );
mbedtls_free( name ); mbedtls_free( name );
} }
} }