summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-01 03:52:20 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-01 03:52:20 +0000
commit24dcb1285db683ef62be0a552ba551809e7b8a4e (patch)
tree8591e38fac3a58da2f9cfbd82ed6b3a8f3f4284c
parente84000fcbafc4800b58e1fa9ddbb2d99bed0b5b7 (diff)
explicit_bzero.c: needs windows.h
* missing/explicit_bzero.c, random.c (explicit_bzero): SecureZeroMemory() needs windows.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--include/ruby/missing.h2
-rw-r--r--missing/explicit_bzero.c6
-rw-r--r--random.c1
-rw-r--r--win32/Makefile.sub1
4 files changed, 9 insertions, 1 deletions
diff --git a/include/ruby/missing.h b/include/ruby/missing.h
index cec0d1ca76..1d7d2b8a82 100644
--- a/include/ruby/missing.h
+++ b/include/ruby/missing.h
@@ -252,7 +252,7 @@ explicit_bzero_by_memset_s(void *b, size_t len)
memset_s(b, len, 0, len);
}
# define explicit_bzero(b, len) explicit_bzero_by_memset_s(b, len)
-# elif defined _WIN32
+# elif defined SecureZeroMemory
# define explicit_bzero(b, len) SecureZeroMemory(b, len)
# endif
#endif
diff --git a/missing/explicit_bzero.c b/missing/explicit_bzero.c
index c1933bf1ff..99b2e2758c 100644
--- a/missing/explicit_bzero.c
+++ b/missing/explicit_bzero.c
@@ -1,6 +1,10 @@
#include "ruby/missing.h"
#include <string.h>
+#ifdef _WIN32
+#include <windows.h>
+#endif
+
/*
*BSD have explicit_bzero().
Windows, OS-X have memset_s().
@@ -30,6 +34,8 @@ explicit_bzero(void *b, size_t len)
{
#ifdef HAVE_MEMSET_S
memset_s(b, len, 0, len);
+#elif defined SecureZeroMemory
+ SecureZeroMemory(b, len);
#else
{
/*
diff --git a/random.c b/random.c
index 3fde5c3495..0ce2aef284 100644
--- a/random.c
+++ b/random.c
@@ -89,6 +89,7 @@ The original copyright notice follows.
# define _WIN32_WINNT 0x400
# undef __WINCRYPT_H__
# endif
+#include <windows.h>
#include <wincrypt.h>
#endif
#include "ruby_atomic.h"
diff --git a/win32/Makefile.sub b/win32/Makefile.sub
index b74d44ee14..751cdb24ea 100644
--- a/win32/Makefile.sub
+++ b/win32/Makefile.sub
@@ -244,6 +244,7 @@ MISSING = crypt.obj ffs.obj langinfo.obj lgamma_r.obj strlcat.obj strlcpy.obj wi
!if $(RT_VER) < 120
MISSING = $(MISSING) acosh.obj cbrt.obj erf.obj tgamma.obj
!endif
+MISSING = $(MISSING) explicit_bzero.obj
!endif
DLNOBJ = dln.obj