From: Pavel Filipenský Date: Mon, 8 Aug 2022 15:47:28 +0000 (+0200) Subject: lib:replace: Add macro BURN_STR() to zero memory of a string X-Git-Tag: talloc-2.4.0~1328 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8564380346ace981b957bb8464f2ecf007032062;p=thirdparty%2Fsamba.git lib:replace: Add macro BURN_STR() to zero memory of a string Signed-off-by: Pavel Filipenský Reviewed-by: Andreas Schneider --- diff --git a/lib/replace/replace.h b/lib/replace/replace.h index da5526c4a2f..bd7f6e53e81 100644 --- a/lib/replace/replace.h +++ b/lib/replace/replace.h @@ -864,6 +864,17 @@ typedef unsigned long long ptrdiff_t ; */ #define BURN_PTR_SIZE(x, s) memset_s((x), (s), 0, (s)) +/** + * Explicitly zero data in string. This is guaranteed to be not optimized + * away. + */ +#define BURN_STR(x) do { \ + if ((x) != NULL) { \ + size_t s = strlen(x); \ + memset_s((x), s, 0, s); \ + } \ + } while(0) + /** * Work out how many elements there are in a static array. */