summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-05 01:49:35 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-05 01:49:35 (GMT)
commit4a066896af896a7f8098537ae4e728a405bb80f2 (patch)
tree4bdccfebbcb7e775e214e412ff6d2526cceab719
parent903161e0af9b52b6ec182783744abcb7170d522a (diff)
random.c: use arc4random_buf
* random.c (fill_random_bytes_syscall): use arc4random_buf if available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--configure.in1
-rw-r--r--random.c5
3 files changed, 10 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index d169fe4..488d797 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu May 5 10:49:33 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * random.c (fill_random_bytes_syscall): use arc4random_buf if
+ available.
+
Wed May 4 23:13:58 2016 Yuichiro Kaneko <yui-knk@ruby-lang.org>
* numeric.c (fix_plus): Remove rb_nucomp_add prototype
diff --git a/configure.in b/configure.in
index 43af2bd..d24619e 100644
--- a/configure.in
+++ b/configure.in
@@ -2270,6 +2270,7 @@ AC_CHECK_FUNCS(_longjmp) # used for AC_ARG_WITH(setjmp-type)
test x$ac_cv_func__longjmp = xno && ac_cv_func__setjmp=no
AC_CHECK_FUNCS(_setjmp) # used for AC_ARG_WITH(setjmp-type)
AC_CHECK_FUNCS(_setjmpex) # used for AC_ARG_WITH(setjmp-type)
+AC_CHECK_FUNCS(arc4random_buf)
AC_CHECK_FUNCS(atan2l atan2f)
AC_CHECK_FUNCS(chroot)
AC_CHECK_FUNCS(chsize)
diff --git a/random.c b/random.c
index 06c66ca..31e7db2 100644
--- a/random.c
+++ b/random.c
@@ -480,7 +480,10 @@ fill_random_bytes_urandom(void *seed, size_t size)
# define fill_random_bytes_urandom(seed, size) -1
#endif
-#if defined(_WIN32)
+#if 0
+#elif defined(HAVE_ARC4RANDOM_BUF)
+#define fill_random_bytes_syscall(buf, size, unused) (arc4random_buf(buf, size), 0)
+#elif defined(_WIN32)
static void
release_crypt(void *p)
{