diff options
-rw-r--r-- | ConfigureChecks.cmake | 2 | ||||
-rw-r--r-- | include/libssh/priv.h | 16 | ||||
-rw-r--r-- | src/misc.c | 11 |
3 files changed, 13 insertions, 16 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 4b03d537..b008d5c3 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -291,7 +291,7 @@ int main(void) { char buf[] = \"This is some content\"; - memset(buf, '\\\\0', sizeof(buf)); __asm__ volatile(\"\" : : \"r\"(&buf) : \"memory\"); + memset(buf, '\\\\0', sizeof(buf)); __asm__ volatile(\"\" : : \"g\"(&buf) : \"memory\"); return 0; }" HAVE_GCC_VOLATILE_MEMORY_PROTECTION) diff --git a/include/libssh/priv.h b/include/libssh/priv.h index d191a9f5..f99e769e 100644 --- a/include/libssh/priv.h +++ b/include/libssh/priv.h @@ -281,21 +281,7 @@ int ssh_connector_remove_event(ssh_connector connector); #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) -#define explicit_bzero(s, n) do { \ - if ((s) != NULL) { \ - void *_x = (s); \ - memset((_x), '\0', (n)); __asm__ volatile("" : : "r"(&(_x)) : "memory"); \ - } \ -} while (0) -#else /* HAVE_GCC_VOLATILE_MEMORY_PROTECTION */ -#define explicit_bzero(s, n) do { \ - memset((s), '\0', (n)); \ -} while (0) -#endif /* HAVE_GCC_VOLATILE_MEMORY_PROTECTION */ +void explicit_bzero(void *s, size_t n); #endif /* !HAVE_EXPLICIT_BZERO */ /** @@ -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: */ |