From: Andreas Schneider Date: Tue, 19 Jul 2022 11:36:57 +0000 (+0200) Subject: lib:replace: Add macros to burn data from memory X-Git-Tag: samba-4.17.0rc1~241 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8b22b448e84269f6f18c0e08d9ff1f0edeae0d31;p=thirdparty%2Fsamba.git lib:replace: Add macros to burn data from memory This will explicitly zero data from memory. This is guaranteed to be not optimized away. Signed-off-by: Andreas Schneider Reviewed-by: Stefan Metzmacher --- diff --git a/lib/replace/replace.h b/lib/replace/replace.h index a8910e2b5e4..da5526c4a2f 100644 --- a/lib/replace/replace.h +++ b/lib/replace/replace.h @@ -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. */