ruby-changes:47761
From: usa <ko1@a...>
Date: Thu, 14 Sep 2017 13:16:57 +0900 (JST)
Subject: [ruby-changes:47761] usa:r59879 (ruby_2_3): * ext/bigdecimal/bigdecimal.c (BigDecimal_hash): st_index_t may not be
usa 2017-09-14 13:16:51 +0900 (Thu, 14 Sep 2017) New Revision: 59879 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59879 Log: * ext/bigdecimal/bigdecimal.c (BigDecimal_hash): st_index_t may not be fixable on 64bit mswin/mingw. * ext/date/date_core.c (d_lite_hash): ditto. [Backport #13877] * ext/openssl/ossl_bn.c (ossl_bn_hash): ditto. Modified files: branches/ruby_2_3/ChangeLog branches/ruby_2_3/ext/bigdecimal/bigdecimal.c branches/ruby_2_3/ext/date/date_core.c branches/ruby_2_3/ext/openssl/ossl_bn.c branches/ruby_2_3/test/bigdecimal/test_bigdecimal.rb branches/ruby_2_3/test/date/test_date.rb branches/ruby_2_3/test/openssl/test_bn.rb branches/ruby_2_3/version.h Index: ruby_2_3/ext/bigdecimal/bigdecimal.c =================================================================== --- ruby_2_3/ext/bigdecimal/bigdecimal.c (revision 59878) +++ ruby_2_3/ext/bigdecimal/bigdecimal.c (revision 59879) @@ -376,7 +376,7 @@ BigDecimal_hash(VALUE self) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ext/bigdecimal/bigdecimal.c#L376 hash ^= rb_memhash(p->frac, sizeof(BDIGIT)*p->Prec); hash += p->exponent; } - return INT2FIX(hash); + return LONG2FIX((long)hash); } /* Index: ruby_2_3/ext/date/date_core.c =================================================================== --- ruby_2_3/ext/date/date_core.c (revision 59878) +++ ruby_2_3/ext/date/date_core.c (revision 59879) @@ -6405,7 +6405,7 @@ d_lite_hash(VALUE self) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ext/date/date_core.c#L6405 h[2] = m_df(dat); h[3] = m_sf(dat); v = rb_memhash(h, sizeof(h)); - return LONG2FIX(v); + return LONG2FIX((long)v); } #include "date_tmx.h" Index: ruby_2_3/ext/openssl/ossl_bn.c =================================================================== --- ruby_2_3/ext/openssl/ossl_bn.c (revision 59878) +++ ruby_2_3/ext/openssl/ossl_bn.c (revision 59879) @@ -912,7 +912,7 @@ ossl_bn_hash(VALUE self) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ext/openssl/ossl_bn.c#L912 ossl_raise(eBNError, NULL); } - hash = INT2FIX(rb_memhash(buf, len)); + hash = LONG2FIX((long)rb_memhash(buf, len)); xfree(buf); return hash; Index: ruby_2_3/ChangeLog =================================================================== --- ruby_2_3/ChangeLog (revision 59878) +++ ruby_2_3/ChangeLog (revision 59879) @@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1 +Thu Sep 14 13:14:19 2017 NAKAMURA Usaku <usa@r...> + + * ext/bigdecimal/bigdecimal.c (BigDecimal_hash): st_index_t may not be + fixable on 64bit mswin/mingw. + + * ext/date/date_core.c (d_lite_hash): ditto. + [Backport #13877] + + * ext/openssl/ossl_bn.c (ossl_bn_hash): ditto. + Sat Sep 9 23:05:31 2017 Kazuki Yamaguchi <k@r...> asn1: fix out-of-bounds read in decoding constructed objects Index: ruby_2_3/test/date/test_date.rb =================================================================== --- ruby_2_3/test/date/test_date.rb (revision 59878) +++ ruby_2_3/test/date/test_date.rb (revision 59879) @@ -129,6 +129,8 @@ class TestDate < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/date/test_date.rb#L129 assert_equal(3, h.size) assert_equal(9, h[Date.new(1999,5,25)]) assert_equal(9, h[DateTime.new(1999,5,25)]) + + assert_instance_of(String, Date.new(1999,5,25).hash.to_s) end def test_freeze Index: ruby_2_3/test/bigdecimal/test_bigdecimal.rb =================================================================== --- ruby_2_3/test/bigdecimal/test_bigdecimal.rb (revision 59878) +++ ruby_2_3/test/bigdecimal/test_bigdecimal.rb (revision 59879) @@ -521,6 +521,7 @@ class TestBigDecimal < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/bigdecimal/test_bigdecimal.rb#L521 a.each_with_index do |x, i| assert_equal(i, h[x]) end + assert_instance_of(String, b.hash.to_s) end def test_marshal Index: ruby_2_3/test/openssl/test_bn.rb =================================================================== --- ruby_2_3/test/openssl/test_bn.rb (revision 59878) +++ ruby_2_3/test/openssl/test_bn.rb (revision 59879) @@ -56,6 +56,25 @@ class OpenSSL::TestBN < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/openssl/test_bn.rb#L56 assert_equal(bn1.hash, bn2.hash) assert_not_equal(bn3.hash, bn1.hash) end + + def test_comparison + e1 = OpenSSL::BN.new(999.to_s(16), 16) + e3 = OpenSSL::BN.new((2**107-1).to_s(16), 16) + assert_equal(false, e1 == nil) + assert_equal(false, e1 == -999) + assert_equal(true, e1 == 999) + assert_equal(true, e1 == 999.to_bn) + assert_equal(false, e1.eql?(nil)) + assert_equal(false, e1.eql?(999)) + assert_equal(true, e1.eql?(999.to_bn)) + assert_equal(e1.hash, 999.to_bn.hash) + assert_not_equal(e1.hash, e3.hash) + assert_equal(0, e1.cmp(999)) + assert_equal(1, e1.cmp(-999)) + assert_equal(0, e1.ucmp(999)) + assert_equal(0, e1.ucmp(-999)) + assert_instance_of(String, e1.hash.to_s) + end end end Index: ruby_2_3/version.h =================================================================== --- ruby_2_3/version.h (revision 59878) +++ ruby_2_3/version.h (revision 59879) @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1 #define RUBY_VERSION "2.3.5" -#define RUBY_RELEASE_DATE "2017-09-09" -#define RUBY_PATCHLEVEL 369 +#define RUBY_RELEASE_DATE "2017-09-14" +#define RUBY_PATCHLEVEL 370 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 9 -#define RUBY_RELEASE_DAY 9 +#define RUBY_RELEASE_DAY 14 #include "ruby/version.h" -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/