diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2012-11-23 11:56:21 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2012-11-23 11:56:21 +0100 |
commit | ea0e858de08a12b1120b4ebb8fdddc81770c9651 (patch) | |
tree | 829b003de337881d097a7641d5341c61d9abf2a7 /include/libssh | |
parent | e403596d98b056fa496f1fd5e18a66a416a17e8a (diff) | |
download | libssh-ea0e858de08a12b1120b4ebb8fdddc81770c9651.tar.gz libssh-ea0e858de08a12b1120b4ebb8fdddc81770c9651.tar.xz libssh-ea0e858de08a12b1120b4ebb8fdddc81770c9651.zip |
priv: Add BURN_BUFFER macro and make sure it isn't optimzed out.
Diffstat (limited to 'include/libssh')
-rw-r--r-- | include/libssh/priv.h | 7 |
1 files changed, 5 insertions, 2 deletions
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 |