aboutsummaryrefslogtreecommitdiff
path: root/src/misc.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2018-03-02 17:55:51 +0100
committerAndreas Schneider <asn@cryptomilk.org>2018-03-02 18:07:42 +0100
commit81847bf5135d836000d206d559df2e27f9a00a84 (patch)
tree16824a3f76f933df790ad5d221388e1e5d7c1f54 /src/misc.c
parentbba40abc7603fbb3e4f5089684845312b789aff7 (diff)
downloadlibssh-81847bf5135d836000d206d559df2e27f9a00a84.tar.gz
libssh-81847bf5135d836000d206d559df2e27f9a00a84.tar.xz
libssh-81847bf5135d836000d206d559df2e27f9a00a84.zip
priv: Implement explicit_bzero as a function if not available
Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Alberto Aguirre <albaguirre@gmail.com>
Diffstat (limited to 'src/misc.c')
-rw-r--r--src/misc.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/misc.c b/src/misc.c
index 9ef31184..ac3a623c 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -1052,6 +1052,17 @@ int ssh_match_group(const char *group, const char *object)
return 0;
}
+#if !defined(HAVE_EXPLICIT_BZERO)
+void explicit_bzero(void *s, size_t n)
+{
+ memset(s, '\0', n);
+#if defined(HAVE_GCC_VOLATILE_MEMORY_PROTECTION)
+ /* See http://llvm.org/bugs/show_bug.cgi?id=15495 */
+ __asm__ volatile("" : : "g"(s) : "memory");
+#endif /* HAVE_GCC_VOLATILE_MEMORY_PROTECTION */
+}
+#endif /* !HAVE_EXPLICIT_BZERO */
+
/** @} */
/* vim: set ts=4 sw=4 et cindent: */