diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-11 12:44:51 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-11 12:44:51 +0000 |
commit | 3b08df649e2337594f398e7f47b7baea8188ed96 (patch) | |
tree | 87de6ec738768636d507c0a31eae09a1b47037a6 /numeric.c | |
parent | bfa3d672d14df15fb286b1609c5faaa4d0094000 (diff) | |
download | ruby-3b08df649e2337594f398e7f47b7baea8188ed96.tar.gz |
lib/securerandom.rb: test one byte to determine urandom or openssl
`SecureRandom#gen_random` determines whether urandom is available or not
by trying `Random.urandom(n)`. But, when n = 0, `Random.urandom(0)`
always succeeds even if urandom is not available, which leads to a wrong
decision.
When failed, `Random.urandom` returns nil instead of returning a shorter
string than required. So the check for `ret.length != n` is not needed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
0 files changed, 0 insertions, 0 deletions