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

misc: Use SecureZeroMemory if available for explicit_bzero

Useful on Windows platforms where SecureZeroMemory is available.

Signed-off-by: Alberto Aguirre <albaguirre@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Alberto Aguirre
2018-03-02 15:01:01 -06:00
committed by Andreas Schneider
parent 3fa0e3959c
commit 7e1e0e5098
3 changed files with 7 additions and 0 deletions

View File

@@ -180,6 +180,8 @@ if (WIN32)
check_function_exists(_strtoui64 HAVE__STRTOUI64) check_function_exists(_strtoui64 HAVE__STRTOUI64)
set(HAVE_SELECT TRUE) set(HAVE_SELECT TRUE)
check_symbol_exists(SecureZeroMemory "windows.h" HAVE_SECURE_ZERO_MEMORY)
else (WIN32) else (WIN32)
check_function_exists(poll HAVE_POLL) check_function_exists(poll HAVE_POLL)
check_function_exists(select HAVE_SELECT) check_function_exists(select HAVE_SELECT)

View File

@@ -166,6 +166,9 @@
/* Define to 1 if you have the `memset_s' function. */ /* Define to 1 if you have the `memset_s' function. */
#cmakedefine HAVE_MEMSET_S 1 #cmakedefine HAVE_MEMSET_S 1
/* Define to 1 if you have the `SecureZeroMemory' function. */
#cmakedefine HAVE_SECURE_ZERO_MEMORY 1
/*************************** LIBRARIES ***************************/ /*************************** LIBRARIES ***************************/
/* Define to 1 if you have the `crypto' library (-lcrypto). */ /* Define to 1 if you have the `crypto' library (-lcrypto). */

View File

@@ -1057,6 +1057,8 @@ void explicit_bzero(void *s, size_t n)
{ {
#if defined(HAVE_MEMSET_S) #if defined(HAVE_MEMSET_S)
memset_s(s, n, '\0', n); memset_s(s, n, '\0', n);
#elif defined(HAVE_SECURE_ZERO_MEMORY)
SecureZeroMemory(s, n);
#else #else
memset(s, '\0', n); memset(s, '\0', n);
#if defined(HAVE_GCC_VOLATILE_MEMORY_PROTECTION) #if defined(HAVE_GCC_VOLATILE_MEMORY_PROTECTION)