]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib:replace: Add macros to burn data from memory
authorAndreas Schneider <asn@samba.org>
Tue, 19 Jul 2022 11:36:57 +0000 (13:36 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 28 Jul 2022 11:51:28 +0000 (11:51 +0000)
This will explicitly zero data from memory. This is guaranteed to be not
optimized away.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
lib/replace/replace.h

index a8910e2b5e4cbaee90a899b8eab0d484bbb8e821..da5526c4a2f77cf6c8f5552b9b300da7d5f071fa 100644 (file)
@@ -846,6 +846,24 @@ typedef unsigned long long ptrdiff_t ;
  */
 #define ZERO_ARRAY_LEN(x, l) memset_s((char *)(x), (l), 0, (l))
 
+/**
+ * Explicitly zero data from memory. This is guaranteed to be not optimized
+ * away.
+ */
+#define BURN_DATA(x) memset_s((char *)&(x), sizeof(x), 0, sizeof(x))
+
+/**
+ * Explicitly zero data from memory. This is guaranteed to be not optimized
+ * away.
+ */
+#define BURN_DATA_SIZE(x, s) memset_s((char *)&(x), (s), 0, (s))
+
+/**
+ * Explicitly zero data from memory. This is guaranteed to be not optimized
+ * away.
+ */
+#define BURN_PTR_SIZE(x, s) memset_s((x), (s), 0, (s))
+
 /**
  * Work out how many elements there are in a static array.
  */