summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--random.c5
2 files changed, 10 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 799d58656e..a878806aa1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun Oct 18 14:37:56 2015 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
+
+ * random.c (fill_random_bytes_urandom): add a comment why using
+ O_NONBLOCK and O_NOCTTY.
+
Sun Oct 18 13:30:56 2015 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* random.c (fill_random_bytes_syscall): don't use GRND_NONBLOCK.
diff --git a/random.c b/random.c
index 3fcc4243e6..e73e3dec06 100644
--- a/random.c
+++ b/random.c
@@ -455,6 +455,11 @@ random_init(int argc, VALUE *argv, VALUE obj)
static int
fill_random_bytes_urandom(void *seed, size_t size)
{
+ /*
+ O_NONBLOCK and O_NOCTTY is meaningless if /dev/urandom correctly point
+ to urandom device. But it protect from several strange hazard if
+ /dev/urandom is not urandom device.
+ */
int fd = rb_cloexec_open("/dev/urandom",
# ifdef O_NONBLOCK
O_NONBLOCK|