[前][次][番号順一覧][スレッド一覧]

ruby-changes:40100

From: kosaki <ko1@a...>
Date: Sun, 18 Oct 2015 14:43:13 +0900 (JST)
Subject: [ruby-changes:40100] kosaki:r52181 (trunk): * random.c (fill_random_bytes_urandom): add a comment why using

kosaki	2015-10-18 14:43:08 +0900 (Sun, 18 Oct 2015)

  New Revision: 52181

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52181

  Log:
    * random.c (fill_random_bytes_urandom): add a comment why using
      O_NONBLOCK and O_NOCTTY.

  Modified files:
    trunk/ChangeLog
    trunk/random.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52180)
+++ ChangeLog	(revision 52181)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Oct 18 14:37:56 2015  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* 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@g...>
 
 	* random.c (fill_random_bytes_syscall): don't use GRND_NONBLOCK.
Index: random.c
===================================================================
--- random.c	(revision 52180)
+++ random.c	(revision 52181)
@@ -455,6 +455,11 @@ random_init(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/random.c#L455
 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|

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]