ruby-changes:55317
From: naruse <ko1@a...>
Date: Sat, 13 Apr 2019 16:33:16 +0900 (JST)
Subject: [ruby-changes:55317] naruse:r67524 (ruby_2_6): merge revision(s) 67497, 67498: [Backport #15760]
naruse 2019-04-13 16:33:10 +0900 (Sat, 13 Apr 2019) New Revision: 67524 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67524 Log: merge revision(s) 67497,67498: [Backport #15760] ext/openssl/ossl_bn.c (ossl_bn_initialize): get rid of SEGV OpenSSL::BN.new(nil, 2) dumped core. [ruby-core:92231] [Bug #15760] * expand tabs. Modified directories: branches/ruby_2_6/ Modified files: branches/ruby_2_6/ext/openssl/ossl_bn.c branches/ruby_2_6/test/openssl/test_bn.rb branches/ruby_2_6/version.h Index: ruby_2_6/ext/openssl/ossl_bn.c =================================================================== --- ruby_2_6/ext/openssl/ossl_bn.c (revision 67523) +++ ruby_2_6/ext/openssl/ossl_bn.c (revision 67524) @@ -187,6 +187,7 @@ ossl_bn_initialize(int argc, VALUE *argv https://github.com/ruby/ruby/blob/trunk/ruby_2_6/ext/openssl/ossl_bn.c#L187 BIGNUM *bn; VALUE str, bs; int base = 10; + char *ptr; if (rb_scan_args(argc, argv, "11", &str, &bs) == 2) { base = NUM2INT(bs); @@ -213,12 +214,14 @@ ossl_bn_initialize(int argc, VALUE *argv https://github.com/ruby/ruby/blob/trunk/ruby_2_6/ext/openssl/ossl_bn.c#L214 GetBN(self, bn); switch (base) { case 0: - if (!BN_mpi2bn((unsigned char *)StringValuePtr(str), RSTRING_LENINT(str), bn)) { + ptr = StringValuePtr(str); + if (!BN_mpi2bn((unsigned char *)ptr, RSTRING_LENINT(str), bn)) { ossl_raise(eBNError, NULL); } break; case 2: - if (!BN_bin2bn((unsigned char *)StringValuePtr(str), RSTRING_LENINT(str), bn)) { + ptr = StringValuePtr(str); + if (!BN_bin2bn((unsigned char *)ptr, RSTRING_LENINT(str), bn)) { ossl_raise(eBNError, NULL); } break; Index: ruby_2_6/test/openssl/test_bn.rb =================================================================== --- ruby_2_6/test/openssl/test_bn.rb (revision 67523) +++ ruby_2_6/test/openssl/test_bn.rb (revision 67524) @@ -272,6 +272,11 @@ class OpenSSL::TestBN < OpenSSL::TestCas https://github.com/ruby/ruby/blob/trunk/ruby_2_6/test/openssl/test_bn.rb#L272 assert_equal(0, @e1.ucmp(-999)) assert_instance_of(String, @e1.hash.to_s) end + + def test_type_error + bug15760 = '[ruby-core:92231] [Bug #15760]' + assert_raise(TypeError, bug15760) { OpenSSL::BN.new(nil, 2) } + end end end Index: ruby_2_6/version.h =================================================================== --- ruby_2_6/version.h (revision 67523) +++ ruby_2_6/version.h (revision 67524) @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_6/version.h#L1 #define RUBY_VERSION "2.6.3" #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 54 +#define RUBY_PATCHLEVEL 55 #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 4 -#define RUBY_RELEASE_DAY 11 +#define RUBY_RELEASE_DAY 13 #include "ruby/version.h" Index: ruby_2_6 =================================================================== --- ruby_2_6 (revision 67523) +++ ruby_2_6 (revision 67524) Property changes on: ruby_2_6 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r67497-67498 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/