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

ruby-changes:36243

From: usa <ko1@a...>
Date: Sun, 9 Nov 2014 05:01:34 +0900 (JST)
Subject: [ruby-changes:36243] usa:r48324 (trunk): * lib/securerandom.rb (initialize): call the special method for Win32

usa	2014-11-09 05:01:24 +0900 (Sun, 09 Nov 2014)

  New Revision: 48324

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

  Log:
    * lib/securerandom.rb (initialize): call the special method for Win32
      before cheking `/dev/urandom` because we know windows doesn't have it.

  Modified files:
    trunk/ChangeLog
    trunk/lib/securerandom.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48323)
+++ ChangeLog	(revision 48324)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Nov  9 05:00:23 2014  NAKAMURA Usaku  <usa@r...>
+
+	* lib/securerandom.rb (initialize): call the special method for Win32
+	  before cheking `/dev/urandom` because we know windows doesn't have it.
+
 Sun Nov  9 04:01:46 2014  NAKAMURA Usaku  <usa@r...>
 
 	* lib/securerandom.rb (SecureRandom::AdvApi32): split from `initialize`.
Index: lib/securerandom.rb
===================================================================
--- lib/securerandom.rb	(revision 48323)
+++ lib/securerandom.rb	(revision 48324)
@@ -119,6 +119,10 @@ module SecureRandom https://github.com/ruby/ruby/blob/trunk/lib/securerandom.rb#L119
       return OpenSSL::Random.random_bytes(n)
     end
 
+    if defined?(AdvApi32)
+      return AdvApi32.gen_random(n)
+    end
+
     if !defined?(@has_urandom) || @has_urandom
       flags = File::RDONLY
       flags |= File::NONBLOCK if defined? File::NONBLOCK
@@ -140,10 +144,6 @@ module SecureRandom https://github.com/ruby/ruby/blob/trunk/lib/securerandom.rb#L144
       end
     end
 
-    if defined?(AdvApi32)
-      return AdvApi32.gen_random(n)
-    end
-
     raise NotImplementedError, "No random device"
   end
 

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

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