]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib:replace: Add macro BURN_STR() to zero memory of a string
authorPavel Filipenský <pfilipensky@samba.org>
Mon, 8 Aug 2022 15:47:28 +0000 (17:47 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 26 Aug 2022 07:59:32 +0000 (07:59 +0000)
Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
lib/replace/replace.h

index da5526c4a2f77cf6c8f5552b9b300da7d5f071fa..bd7f6e53e818689d12881ada491c0b50ccf4ae90 100644 (file)
@@ -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.
  */