Skip to content

Commit

Permalink
Fix conditional check for HAVE_DECL_SECUREZEROMEMORY
Browse files Browse the repository at this point in the history
"Unlike the other `AC_CHECK_*S' macros, when a symbol is not declared,
HAVE_DECL_symbol is defined to `0' instead of leaving HAVE_DECL_symbol
undeclared. When you are sure that the check was performed,
use HAVE_DECL_symbol in #if."

Source: autoconf documentation for AC_CHECK_DECLS.
  • Loading branch information
mback2k committed Sep 2, 2018
1 parent ee89d17 commit 8b870ad
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@
#include <sys/time.h>
#endif

#ifdef HAVE_DECL_SECUREZEROMEMORY
#if defined(HAVE_DECL_SECUREZEROMEMORY) && HAVE_DECL_SECUREZEROMEMORY
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif
#endif

#include <stdio.h>
#include <errno.h>
Expand Down Expand Up @@ -689,7 +691,7 @@ static void * (* const volatile memset_libssh)(void *, int, size_t) = memset;

void _libssh2_explicit_zero(void *buf, size_t size)
{
#ifdef HAVE_DECL_SECUREZEROMEMORY
#if defined(HAVE_DECL_SECUREZEROMEMORY) && HAVE_DECL_SECUREZEROMEMORY
SecureZeroMemory(buf, size);
#elif defined(HAVE_MEMSET_S)
(void)memset_s(buf, size, 0, size);
Expand Down

0 comments on commit 8b870ad

Please sign in to comment.