1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-29 01:03:57 +03:00

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>
This commit is contained in:
Andreas Schneider
2018-03-02 17:55:51 +01:00
parent bba40abc76
commit 81847bf513
3 changed files with 13 additions and 16 deletions

View File

@@ -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: */