aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2018-02-12 14:35:55 +0100
committerAndreas Schneider <asn@cryptomilk.org>2018-02-12 14:41:27 +0100
commitebcff9fd630f8bd26b0cda23e39c63805f2b781b (patch)
tree117d6f7a61ebf2dbef4df9e3f09f487077afb79c /include
parent25ff1214a40531cea33a91eed6225d4f4bf51cbc (diff)
downloadlibssh-ebcff9fd630f8bd26b0cda23e39c63805f2b781b.tar.gz
libssh-ebcff9fd630f8bd26b0cda23e39c63805f2b781b.tar.xz
libssh-ebcff9fd630f8bd26b0cda23e39c63805f2b781b.zip
src: Use explicit_bzero() if available on the platform
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'include')
-rw-r--r--include/libssh/priv.h31
1 files changed, 10 insertions, 21 deletions
diff --git a/include/libssh/priv.h b/include/libssh/priv.h
index c2d20b2d..1a842182 100644
--- a/include/libssh/priv.h
+++ b/include/libssh/priv.h
@@ -280,33 +280,22 @@ int ssh_connector_remove_event(ssh_connector connector);
/** Get the size of an array */
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
+#ifndef HAVE_EXPLICIT_BZERO
/*
* See http://llvm.org/bugs/show_bug.cgi?id=15495
*/
#if defined(HAVE_GCC_VOLATILE_MEMORY_PROTECTION)
-/** Overwrite a string with '\0' */
-# define BURN_STRING(x) do { \
- if ((x) != NULL) \
- memset((x), '\0', strlen((x))); __asm__ volatile("" : : "r"(&(x)) : "memory"); \
- } while(0)
-
-/** Overwrite the buffer with '\0' */
-# define BURN_BUFFER(x, size) do { \
- if ((x) != NULL) \
- memset((x), '\0', (size)); __asm__ volatile("" : : "r"(&(x)) : "memory"); \
- } while(0)
+#define explicit_bzero(s, n) do { \
+ if ((s) != NULL) { \
+ memset((s), '\0', (n)); __asm__ volatile("" : : "r"(&(s)) : "memory"); \
+ } \
+} while (0)
#else /* HAVE_GCC_VOLATILE_MEMORY_PROTECTION */
-/** Overwrite a string with '\0' */
-# define BURN_STRING(x) do { \
- if ((x) != NULL) memset((x), '\0', strlen((x))); \
- } while(0)
-
-/** Overwrite the buffer with '\0' */
-# define BURN_BUFFER(x, size) do { \
- if ((x) != NULL) \
- memset((x), '\0', (size)); \
- } while(0)
+#define explicit_bzero(s, n) do { \
+ memset((s), '\0', (n)); \
+} while (0)
#endif /* HAVE_GCC_VOLATILE_MEMORY_PROTECTION */
+#endif /* !HAVE_EXPLICIT_BZERO */
/**
* This is a hack to fix warnings. The idea is to use this everywhere that we