ruby-changes:37763
From: odaira <ko1@a...>
Date: Thu, 5 Mar 2015 08:45:16 +0900 (JST)
Subject: [ruby-changes:37763] odaira:r49844 (trunk): * random.c (random_raw_seed): Avoid calling fill_random_bytes()
odaira 2015-03-05 08:44:59 +0900 (Thu, 05 Mar 2015) New Revision: 49844 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49844 Log: * 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. Modified files: trunk/ChangeLog trunk/random.c Index: ChangeLog =================================================================== --- ChangeLog (revision 49843) +++ ChangeLog (revision 49844) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Mar 5 08:31:02 2015 Rei Odaira <Rei.Odaira@g...> + + * 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@r...> * test/ruby/test_math.rb (assert_float_and_int): Refactor test cases Index: random.c =================================================================== --- random.c (revision 49843) +++ random.c (revision 49844) @@ -580,6 +580,7 @@ random_raw_seed(VALUE self, VALUE size) https://github.com/ruby/ruby/blob/trunk/random.c#L580 { 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; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/