From 970ce1fd0987f4a4943f38a32a010f01940d78d6 Mon Sep 17 00:00:00 2001 From: yugui Date: Sun, 3 Jul 2011 12:23:58 +0000 Subject: 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@32381 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ lib/securerandom.rb | 8 ++++++++ version.h | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 5873dac0d0..efc66e8520 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Jun 13 18:33:04 2011 Tanaka Akira + + * 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 * io.c (io_getc): should be 7bit if ascii. fixes #4557 diff --git a/lib/securerandom.rb b/lib/securerandom.rb index 1c88a61fd7..5f8f69836d 100644 --- a/lib/securerandom.rb +++ b/lib/securerandom.rb @@ -57,6 +57,14 @@ module SecureRandom 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 diff --git a/version.h b/version.h index ac7dc379d2..acafe142b0 100644 --- a/version.h +++ b/version.h @@ -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 -- cgit v1.2.3