merge revision(s) 35545,35564,35565:

* lib/securerandom.rb: show actual read length in an error message.

	* lib/securerandom.rb (random_bytes): call to_int method for the
	  argument at first.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@35566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2012-05-07 11:25:45 +00:00
parent f4be1257a4
commit 2099780eb6
3 changed files with 12 additions and 3 deletions

View file

@ -1,3 +1,12 @@
Mon May 7 20:23:29 2012 Tanaka Akira <akr@fsij.org>
* lib/securerandom.rb (random_bytes): call to_int method for the
argument at first.
Mon May 7 20:23:29 2012 Tanaka Akira <akr@fsij.org>
* lib/securerandom.rb: show actual read length in an error message.
Mon May 7 11:09:20 2012 NARUSE, Yui <naruse@ruby-lang.org> Mon May 7 11:09:20 2012 NARUSE, Yui <naruse@ruby-lang.org>
* ext/bigdecimal/bigdecimal.c (Init_bigdecimal): define IDs before * ext/bigdecimal/bigdecimal.c (Init_bigdecimal): define IDs before

View file

@ -54,7 +54,7 @@ module SecureRandom
# If secure random number generator is not available, # If secure random number generator is not available,
# NotImplementedError is raised. # NotImplementedError is raised.
def self.random_bytes(n=nil) def self.random_bytes(n=nil)
n ||= 16 n = n ? n.to_int : 16
if defined? OpenSSL::Random if defined? OpenSSL::Random
@pid = 0 if !defined?(@pid) @pid = 0 if !defined?(@pid)
@ -80,7 +80,7 @@ module SecureRandom
@has_urandom = true @has_urandom = true
ret = f.readpartial(n) ret = f.readpartial(n)
if ret.length != n if ret.length != n
raise NotImplementedError, "Unexpected partial read from random device" raise NotImplementedError, "Unexpected partial read from random device: only #{ret.length} for #{n} bytes"
end end
return ret return ret
} }

View file

@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.3" #define RUBY_VERSION "1.9.3"
#define RUBY_PATCHLEVEL 205 #define RUBY_PATCHLEVEL 206
#define RUBY_RELEASE_DATE "2012-05-07" #define RUBY_RELEASE_DATE "2012-05-07"
#define RUBY_RELEASE_YEAR 2012 #define RUBY_RELEASE_YEAR 2012