From ea0e858de08a12b1120b4ebb8fdddc81770c9651 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Fri, 23 Nov 2012 11:56:21 +0100 Subject: priv: Add BURN_BUFFER macro and make sure it isn't optimzed out. --- include/libssh/priv.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'include/libssh/priv.h') diff --git a/include/libssh/priv.h b/include/libssh/priv.h index 2e323b9b..4e51e0fd 100644 --- a/include/libssh/priv.h +++ b/include/libssh/priv.h @@ -207,8 +207,11 @@ int match_hostname(const char *host, const char *pattern, unsigned int len); /** Get the size of an array */ #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) -/** Overwrite the complete string with 'X' */ -#define BURN_STRING(x) do { if ((x) != NULL) memset((x), 'X', strlen((x))); } while(0) +/** Overwrite a string with '\0' */ +#define BURN_STRING(x) do { if ((x) != NULL) memset((x), '\0', strlen((x))); __asm__ volatile (""); } while(0) + +/** Overwrite the buffer with '\0' */ +#define BURN_BUFFER(x, size) do { if ((x) != NULL) memset((x), '\0', (size))); __asm__ volatile (""); } while(0) /** * This is a hack to fix warnings. The idea is to use this everywhere that we -- cgit v1.2.3