зеркало из https://github.com/github/ruby.git
* random.c (random_raw_seed): Avoid calling fill_random_bytes()
if the requested size is 0. AIX returns -1 for 0-byte read from /dev/urandom, while other UNIX returns 0. With this change, Random.raw_seed(0) consistently retuns "" in any UNIX. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
1d00e40e0c
Коммит
270630c628
|
@ -1,3 +1,10 @@
|
|||
Thu Mar 5 08:31:02 2015 Rei Odaira <Rei.Odaira@gmail.com>
|
||||
|
||||
* random.c (random_raw_seed): Avoid calling fill_random_bytes()
|
||||
if the requested size is 0. AIX returns -1 for 0-byte read from
|
||||
/dev/urandom, while other UNIX returns 0. With this change,
|
||||
Random.raw_seed(0) consistently retuns "" in any UNIX.
|
||||
|
||||
Wed Mar 4 12:43:32 2015 Kazuki Tanaka <gogotanaka@ruby-lang.org>
|
||||
|
||||
* test/ruby/test_math.rb (assert_float_and_int): Refactor test cases
|
||||
|
|
1
random.c
1
random.c
|
@ -580,6 +580,7 @@ random_raw_seed(VALUE self, VALUE size)
|
|||
{
|
||||
long n = NUM2ULONG(size);
|
||||
VALUE buf = rb_str_new(0, n);
|
||||
if (n == 0) return buf;
|
||||
if (fill_random_bytes(RSTRING_PTR(buf), n)) return Qnil;
|
||||
return buf;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче