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

ruby-changes:20333

From: yugui <ko1@a...>
Date: Sun, 3 Jul 2011 21:24:24 +0900 (JST)
Subject: [ruby-changes:20333] yugui:r32381 (ruby_1_9_2): merges r32050 from trunk into ruby_1_9_2.

yugui	2011-07-03 21:23:58 +0900 (Sun, 03 Jul 2011)

  New Revision: 32381

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

  Log:
    merges r32050 from trunk into ruby_1_9_2.
    --
    * lib/securerandom.rb (SecureRandom.random_bytes): modify PRNG state
      to prevent random number sequence repeatation at forked child
      process which has same pid.
      reported by Eric Wong.  [ruby-core:35765]

  Modified files:
    branches/ruby_1_9_2/ChangeLog
    branches/ruby_1_9_2/lib/securerandom.rb
    branches/ruby_1_9_2/version.h

Index: ruby_1_9_2/ChangeLog
===================================================================
--- ruby_1_9_2/ChangeLog	(revision 32380)
+++ ruby_1_9_2/ChangeLog	(revision 32381)
@@ -1,3 +1,10 @@
+Mon Jun 13 18:33:04 2011  Tanaka Akira  <akr@f...>
+
+	* lib/securerandom.rb (SecureRandom.random_bytes): modify PRNG state
+	  to prevent random number sequence repeatation at forked child
+	  process which has same pid.
+	  reported by Eric Wong.  [ruby-core:35765]
+
 Sat Jun 11 18:02:09 2011  Nobuyoshi Nakada  <nobu@r...>
 
 	* io.c (io_getc): should be 7bit if ascii.  fixes #4557
Index: ruby_1_9_2/lib/securerandom.rb
===================================================================
--- ruby_1_9_2/lib/securerandom.rb	(revision 32380)
+++ ruby_1_9_2/lib/securerandom.rb	(revision 32381)
@@ -57,6 +57,14 @@
     n ||= 16
 
     if defined? OpenSSL::Random
+      @pid = $$ if !defined?(@pid)
+      pid = $$
+      if @pid != pid
+        now = Time.now
+        ary = [now.to_i, now.nsec, @pid, pid]
+        OpenSSL::Random.seed(ary.to_s)
+        @pid = pid
+      end
       return OpenSSL::Random.random_bytes(n)
     end
 
Index: ruby_1_9_2/version.h
===================================================================
--- ruby_1_9_2/version.h	(revision 32380)
+++ ruby_1_9_2/version.h	(revision 32381)
@@ -1,5 +1,5 @@
 #define RUBY_VERSION "1.9.2"
-#define RUBY_PATCHLEVEL 280
+#define RUBY_PATCHLEVEL 281
 #define RUBY_VERSION_MAJOR 1
 #define RUBY_VERSION_MINOR 9
 #define RUBY_VERSION_TEENY 1

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

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