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/debug.c b/library/debug.c
index da4ceac..9c8c2f6 100644
--- a/library/debug.c
+++ b/library/debug.c
@@ -170,7 +170,7 @@
debug_send_line( ssl, level, file, line, str );
idx = 0;
- memset( txt, 0, sizeof( txt ) );
+ mbedtls_platform_memset( txt, 0, sizeof( txt ) );
for( i = 0; i < len; i++ )
{
if( i >= 4096 )
@@ -184,7 +184,7 @@
debug_send_line( ssl, level, file, line, str );
idx = 0;
- memset( txt, 0, sizeof( txt ) );
+ mbedtls_platform_memset( txt, 0, sizeof( txt ) );
}
idx += mbedtls_snprintf( str + idx, sizeof( str ) - idx, "%04x: ",
@@ -309,7 +309,7 @@
mbedtls_pk_debug_item items[MBEDTLS_PK_DEBUG_MAX_ITEMS];
char name[16];
- memset( items, 0, sizeof( items ) );
+ mbedtls_platform_memset( items, 0, sizeof( items ) );
if( mbedtls_pk_debug( pk, items ) != 0 )
{