diff --git a/ChangeLog b/ChangeLog index f6674181d..5ed802507 100644 --- a/ChangeLog +++ b/ChangeLog @@ -66,6 +66,7 @@ API Changes * Signature of mpi_mul_mpi() changed to make the last argument unsigned * calloc() is now used instead of malloc() everywhere. API of platform layer and the memory_buffer_alloc module changed accordingly. + (Thanks to Mansour Moufid for helping with the replacement.) * Change SSL_DISABLE_RENEGOTIATION config.h flag to SSL_RENEGOTIATION (support for renegotiation now needs explicit enabling in config.h). * net_connect() and net_bind() have a new 'proto' argument to choose diff --git a/library/asn1parse.c b/library/asn1parse.c index ae392bb7f..563e9a744 100644 --- a/library/asn1parse.c +++ b/library/asn1parse.c @@ -275,8 +275,6 @@ int mbedtls_asn1_get_sequence_of( unsigned char **p, if( cur->next == NULL ) return( MBEDTLS_ERR_ASN1_MALLOC_FAILED ); - memset( cur->next, 0, sizeof( mbedtls_asn1_sequence ) ); - cur = cur->next; } } diff --git a/library/asn1write.c b/library/asn1write.c index 7862961f7..f5b1849ea 100644 --- a/library/asn1write.c +++ b/library/asn1write.c @@ -316,8 +316,6 @@ mbedtls_asn1_named_data *mbedtls_asn1_store_named_data( mbedtls_asn1_named_data if( ( cur = mbedtls_calloc( 1, sizeof(mbedtls_asn1_named_data) ) ) == NULL ) return( NULL ); - memset( cur, 0, sizeof(mbedtls_asn1_named_data) ); - cur->oid.len = oid_len; cur->oid.p = mbedtls_calloc( 1, oid_len ); if( cur->oid.p == NULL ) diff --git a/library/ssl_cache.c b/library/ssl_cache.c index 6a20cd328..e05bd8831 100644 --- a/library/ssl_cache.c +++ b/library/ssl_cache.c @@ -229,8 +229,6 @@ int mbedtls_ssl_cache_set( void *data, const mbedtls_ssl_session *session ) goto exit; } - memset( cur, 0, sizeof(mbedtls_ssl_cache_entry) ); - if( prv == NULL ) cache->chain = cur; else diff --git a/library/ssl_tls.c b/library/ssl_tls.c index fa4d39e50..76c644bc7 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -2931,8 +2931,6 @@ static int ssl_reassemble_dtls_handshake( mbedtls_ssl_context *ssl ) return( MBEDTLS_ERR_SSL_MALLOC_FAILED ); } - memset( ssl->handshake->hs_msg, 0, alloc_len ); - /* Prepare final header: copy msg_type, length and message_seq, * then add standardised fragment_offset and fragment_length */ memcpy( ssl->handshake->hs_msg, ssl->in_msg, 6 ); @@ -5011,9 +5009,6 @@ int mbedtls_ssl_setup( mbedtls_ssl_context *ssl, return( MBEDTLS_ERR_SSL_MALLOC_FAILED ); } - memset( ssl-> in_buf, 0, len ); - memset( ssl->out_buf, 0, len ); - #if defined(MBEDTLS_SSL_PROTO_DTLS) if( conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) { diff --git a/library/x509.c b/library/x509.c index 3cddc5f46..0e998fc18 100644 --- a/library/x509.c +++ b/library/x509.c @@ -457,8 +457,6 @@ int mbedtls_x509_get_name( unsigned char **p, const unsigned char *end, if( cur->next == NULL ) return( MBEDTLS_ERR_X509_MALLOC_FAILED ); - memset( cur->next, 0, sizeof( mbedtls_x509_name ) ); - cur = cur->next; } @@ -473,8 +471,6 @@ int mbedtls_x509_get_name( unsigned char **p, const unsigned char *end, if( cur->next == NULL ) return( MBEDTLS_ERR_X509_MALLOC_FAILED ); - memset( cur->next, 0, sizeof( mbedtls_x509_name ) ); - cur = cur->next; } } diff --git a/library/x509_crl.c b/library/x509_crl.c index 5c2c7d5ec..62d0a3064 100644 --- a/library/x509_crl.c +++ b/library/x509_crl.c @@ -243,7 +243,6 @@ static int x509_get_entries( unsigned char **p, if( cur_entry->next == NULL ) return( MBEDTLS_ERR_X509_MALLOC_FAILED ); - memset( cur_entry->next, 0, sizeof( mbedtls_x509_crl_entry ) ); cur_entry = cur_entry->next; } } diff --git a/library/x509_crt.c b/library/x509_crt.c index 849ea7bd9..d1749b9e1 100644 --- a/library/x509_crt.c +++ b/library/x509_crt.c @@ -365,7 +365,6 @@ static int x509_get_subject_alt_name( unsigned char **p, return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_MALLOC_FAILED ); - memset( cur->next, 0, sizeof( mbedtls_asn1_sequence ) ); cur = cur->next; }