summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--common.mk1
-rw-r--r--configure.in2
-rw-r--r--include/ruby/missing.h4
-rw-r--r--random.c2
5 files changed, 17 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index f44ddf5..a0b6c23 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Sun Oct 18 17:26:53 2015 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
+
+ * missing/explicit_bzero.c: new file. define explicit_bzero.
+ * common.mk: add a rule for explicit.o.
+ * configure.in: detect explicit_bzero and memset_s.
+ * include/ruby/missing.h: add explicit_bzero.
+ * random.c (init_randomseed): use explicit_bzero() instead of
+ memset(). memset could be eliminated by compiler optimization.
+
Mon Nov 30 18:46:44 2015 NARUSE, Yui <naruse@ruby-lang.org>
* ext/readline/extconf.rb: call dir_config("libedit")
diff --git a/common.mk b/common.mk
index bc56c40..dde72e3 100644
--- a/common.mk
+++ b/common.mk
@@ -705,6 +705,7 @@ alloca.$(OBJEXT): {$(VPATH)}alloca.c {$(VPATH)}config.h
crypt.$(OBJEXT): {$(VPATH)}crypt.c
dup2.$(OBJEXT): {$(VPATH)}dup2.c
erf.$(OBJEXT): {$(VPATH)}erf.c
+explicit_bzero.$(OBJEXT): {$(VPATH)}explicit_bzero.c
finite.$(OBJEXT): {$(VPATH)}finite.c
flock.$(OBJEXT): {$(VPATH)}flock.c
memcmp.$(OBJEXT): {$(VPATH)}memcmp.c
diff --git a/configure.in b/configure.in
index 8d36819..09f0cbe 100644
--- a/configure.in
+++ b/configure.in
@@ -2127,6 +2127,7 @@ AC_REPLACE_FUNCS(cbrt)
AC_REPLACE_FUNCS(crypt)
AC_REPLACE_FUNCS(dup2)
AC_REPLACE_FUNCS(erf)
+AC_REPLACE_FUNCS(explicit_bzero)
AC_REPLACE_FUNCS(ffs)
AC_REPLACE_FUNCS(finite)
AC_REPLACE_FUNCS(flock)
@@ -2255,6 +2256,7 @@ AC_CHECK_FUNCS(malloc_usable_size)
AC_CHECK_FUNCS(malloc_size)
AC_CHECK_FUNCS(mblen)
AC_CHECK_FUNCS(memalign)
+AC_CHECK_FUNCS(memset_s)
AC_CHECK_FUNCS(writev)
AC_CHECK_FUNCS(memrchr)
AC_CHECK_FUNCS(memmem)
diff --git a/include/ruby/missing.h b/include/ruby/missing.h
index d12f496..24156bf 100644
--- a/include/ruby/missing.h
+++ b/include/ruby/missing.h
@@ -242,6 +242,10 @@ RUBY_EXTERN int ruby_close(int);
RUBY_EXTERN void setproctitle(const char *fmt, ...);
#endif
+#ifndef HAVE_EXPLICIT_BZERO
+RUBY_EXTERN void explicit_bzero(void *b, size_t len);
+#endif
+
RUBY_SYMBOL_EXPORT_END
#if defined(__cplusplus)
diff --git a/random.c b/random.c
index 55a6a6f..b0f638d 100644
--- a/random.c
+++ b/random.c
@@ -1456,7 +1456,7 @@ init_randomseed(struct MT *mt, uint32_t initial[DEFAULT_SEED_CNT])
fill_random_seed(initial);
init_by_array(mt, initial, DEFAULT_SEED_CNT);
seed = make_seed_value(initial);
- memset(initial, 0, DEFAULT_SEED_LEN);
+ explicit_bzero(initial, DEFAULT_SEED_LEN);
return seed;
}