summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPavel Filipenský <pfilipensky@samba.org>2022-08-08 17:47:28 +0200
committerJule Anger <janger@samba.org>2022-09-19 04:02:12 +0000
commit3d7a2a3603efcf05708b8f4078c92110fe9779a6 (patch)
tree1f10ffcc1aa8e9a7d3f599bd2b20e56e6a873d82 /lib
parentbeb63ae03b7dd98f2ed58345fc06b659ea5c11b6 (diff)
downloadsamba-3d7a2a3603efcf05708b8f4078c92110fe9779a6.tar.gz
lib:replace: Add macro BURN_STR() to zero memory of a string
Signed-off-by: Pavel Filipenský <pfilipensky@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> (cherry picked from commit 8564380346ace981b957bb8464f2ecf007032062)
Diffstat (limited to 'lib')
-rw-r--r--lib/replace/replace.h11
1 files changed, 11 insertions, 0 deletions
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
@@ -865,6 +865,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.
*/
#ifdef ARRAY_SIZE