diff options
author | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-10-18 05:43:08 +0000 |
---|---|---|
committer | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-10-18 05:43:08 +0000 |
commit | 84fd2d1d61205018c18448b11808c84f6f8b4dd6 (patch) | |
tree | cfcf7fdff116d8f80d02b82d4ee02dd189d39c4a | |
parent | 0198b5738c1c21b378f81c9bdfb4e7d6108f7c5a (diff) | |
download | ruby-84fd2d1d61205018c18448b11808c84f6f8b4dd6.tar.gz |
* random.c (fill_random_bytes_urandom): add a comment why using
O_NONBLOCK and O_NOCTTY.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | random.c | 5 |
2 files changed, 10 insertions, 0 deletions
@@ -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. @@ -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| |