diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-03 12:23:58 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-03 12:23:58 +0000 |
commit | 970ce1fd0987f4a4943f38a32a010f01940d78d6 (patch) | |
tree | 01a76e90ac09e83141184ee5fee1fbc3f5e90d9a | |
parent | 909a92ea6ddf476411c580c8e075dfd078a59ddc (diff) |
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
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | lib/securerandom.rb | 8 | ||||
-rw-r--r-- | version.h | 2 |
3 files changed, 16 insertions, 1 deletions
@@ -1,3 +1,10 @@ +Mon Jun 13 18:33:04 2011 Tanaka Akira <akr@fsij.org> + + * 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@ruby-lang.org> * 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 @@ -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 |