From 07537eb47c94d077cf082ffee0ad8a497dad2636 Mon Sep 17 00:00:00 2001 From: manojampalam Date: Mon, 21 Mar 2016 21:49:04 -0700 Subject: [PATCH] Added right implementation of explicit_bzero --- contrib/win32/openssh/config.h.vs | 2 -- contrib/win32/win32compat/inc/w32posix.h | 5 +++++ contrib/win32/win32compat/misc.c | 5 +++++ openbsd-compat/explicit_bzero.c | 10 ---------- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/contrib/win32/openssh/config.h.vs b/contrib/win32/openssh/config.h.vs index 2424414..9711c5b 100644 --- a/contrib/win32/openssh/config.h.vs +++ b/contrib/win32/openssh/config.h.vs @@ -1707,8 +1707,6 @@ typedef long ssize_t; #define HAVE_EXPLICIT_BZERO -#define explicit_bzero(p,l) memset((void *)(p),0,(size_t)(l)) -#define bzero(p,l) memset((void *)(p),0,(size_t)(l)) #define WIN32_ZLIB_NO 1 diff --git a/contrib/win32/win32compat/inc/w32posix.h b/contrib/win32/win32compat/inc/w32posix.h index e882610..834cfd6 100644 --- a/contrib/win32/win32compat/inc/w32posix.h +++ b/contrib/win32/win32compat/inc/w32posix.h @@ -138,3 +138,8 @@ struct iovec size_t iov_len; }; + +#define bzero(p,l) memset((void *)(p),0,(size_t)(l)) + +void +explicit_bzero(void *b, size_t len); diff --git a/contrib/win32/win32compat/misc.c b/contrib/win32/win32compat/misc.c index c5fd552..0ff4737 100644 --- a/contrib/win32/win32compat/misc.c +++ b/contrib/win32/win32compat/misc.c @@ -10,4 +10,9 @@ int usleep(unsigned int useconds) pid_t waitpid(pid_t pid, int *status, int options) { /* TODO - implement this*/ return 0; +} + +void +explicit_bzero(void *b, size_t len) { + SecureZeroMemory(b, len); } \ No newline at end of file diff --git a/openbsd-compat/explicit_bzero.c b/openbsd-compat/explicit_bzero.c index ac4fcc4..3c85a48 100644 --- a/openbsd-compat/explicit_bzero.c +++ b/openbsd-compat/explicit_bzero.c @@ -23,14 +23,6 @@ explicit_bzero(void *p, size_t n) #else /* HAVE_MEMSET_S */ -#ifdef WIN32_FIXME -void -explicit_bzero(void *p, size_t n) -{ - bzero(p, n); -} -#else - /* * Indirect bzero through a volatile pointer to hopefully avoid * dead-store optimisation eliminating the call. @@ -43,8 +35,6 @@ explicit_bzero(void *p, size_t n) ssh_bzero(p, n); } -#endif /* WIN32_FIXME */ - #endif /* HAVE_MEMSET_S */ #endif /* HAVE_EXPLICIT_BZERO */