mirror of
https://github.com/libssh2/libssh2.git
synced 2025-11-20 02:42:09 +03:00
src: enable clear memory on all platforms
- convert `_libssh2_explicit_zero()` to macro. This allows inlining where supported (e.g. `SecureZeroMemory()`). - replace `SecureZeroMemory()` (in `wincng.c`) and `LIBSSH2_CLEAR_MEMORY`-guarded `memset()` (in `os400qc3.c`) with `_libssh2_explicit_zero()` macro. - delete `LIBSSH2_CLEAR_MEMORY` guards, which enables secure-zeroing universally. - add `LIBSSH2_NO_CLEAR_MEMORY` option to disable secure-zeroing. - while here, delete double/triple inclusion of `misc.h`. `libssh2_priv.h` included it already. Closes #810
This commit is contained in:
12
src/misc.c
12
src/misc.c
@@ -739,20 +739,14 @@ void _libssh2_aes_ctr_increment(unsigned char *ctr,
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(WIN32) && !defined(HAVE_MEMSET_S)
|
||||
#ifdef LIBSSH2_MEMZERO
|
||||
static void * (* const volatile memset_libssh)(void *, int, size_t) = memset;
|
||||
#endif
|
||||
|
||||
void _libssh2_explicit_zero(void *buf, size_t size)
|
||||
void _libssh2_memzero(void *buf, size_t size)
|
||||
{
|
||||
#ifdef WIN32
|
||||
SecureZeroMemory(buf, size);
|
||||
#elif defined(HAVE_MEMSET_S)
|
||||
(void)memset_s(buf, size, 0, size);
|
||||
#else
|
||||
memset_libssh(buf, 0, size);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/* String buffer */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user