Replace memset() with mbedtls_platform_memset()
Steps:
1. sed -i 's/\bmemset(\([^)]\)/mbedtls_platform_memset(\1/g' library/*.c tinycrypt/*.c include/mbedtls/*.h scripts/data_files/*.fmt
2. Manually edit library/platform_util.c to revert to memset() in the
implementations of mbedtls_platform_memset() and mbedtls_platform_memcpy()
3. egrep -n '\<memset\>' library/*.c include/mbedtls/*.h tinycrypt/*.c
The remaining occurrences are in three categories:
a. From point 2 above.
b. In comments.
c. In the initialisation of memset_func, to be changed in a future commit.
diff --git a/library/md2.c b/library/md2.c
index 1c0b3df..fbec008 100644
--- a/library/md2.c
+++ b/library/md2.c
@@ -81,7 +81,7 @@
void mbedtls_md2_init( mbedtls_md2_context *ctx )
{
- memset( ctx, 0, sizeof( mbedtls_md2_context ) );
+ mbedtls_platform_memset( ctx, 0, sizeof( mbedtls_md2_context ) );
}
void mbedtls_md2_free( mbedtls_md2_context *ctx )
@@ -103,9 +103,9 @@
*/
int mbedtls_md2_starts_ret( mbedtls_md2_context *ctx )
{
- memset( ctx->cksum, 0, 16 );
- memset( ctx->state, 0, 46 );
- memset( ctx->buffer, 0, 16 );
+ mbedtls_platform_memset( ctx->cksum, 0, 16 );
+ mbedtls_platform_memset( ctx->state, 0, 46 );
+ mbedtls_platform_memset( ctx->buffer, 0, 16 );
ctx->left = 0;
return( 0 );