Add more protection to mbedtls_platform_zeroize
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
diff --git a/library/platform_util.c b/library/platform_util.c
index 63b7c41..d4574f4 100644
--- a/library/platform_util.c
+++ b/library/platform_util.c
@@ -126,6 +126,15 @@
#else
memset_func(buf, 0, len);
#endif
+
+#if defined(__GNUC__)
+ /* For clang and gcc, pretend that we have some assembly that reads the
+ * zero'd memory as an additional protection against being optimised away. */
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wvla"
+ asm volatile ("" : : "m" (*(char (*)[len]) buf) : );
+#pragma clang diagnostic pop
+#endif
}
}
#endif /* MBEDTLS_PLATFORM_ZEROIZE_ALT */