[前][次][番号順一覧][スレッド一覧]

ruby-changes:27928

From: usa <ko1@a...>
Date: Thu, 28 Mar 2013 18:19:18 +0900 (JST)
Subject: [ruby-changes:27928] usa:r39980 (ruby_1_9_3): merge revision(s) 35159: [Backport #7980]

usa	2013-03-28 18:19:07 +0900 (Thu, 28 Mar 2013)

  New Revision: 39980

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39980

  Log:
    merge revision(s) 35159: [Backport #7980]
    
    * ext/openssl/ossl_asn1.c: raise TypeError when trying to encode nil
      values for Primitive instances. 
    
    * test/openssl/test_asn1.rb: Assert consistent behavior when
      encoding nil values: Primitives raise TypeError, Constructives
      raise NoMethodError.
      Fixes [ruby-core:43009][Bug #6102]

  Modified directories:
    branches/ruby_1_9_3/
  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/ext/openssl/ossl_asn1.c
    branches/ruby_1_9_3/test/openssl/test_asn1.rb
    branches/ruby_1_9_3/version.h

Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 39979)
+++ ruby_1_9_3/ChangeLog	(revision 39980)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ChangeLog#L1
+Thu Mar 28 18:18:49 2013  Martin Bosslet  <Martin.Bosslet@g...>
+
+	* ext/openssl/ossl_asn1.c: raise TypeError when trying to encode nil
+	  values for Primitive instances. 
+	* test/openssl/test_asn1.rb: Assert consistent behavior when
+	  encoding nil values: Primitives raise TypeError, Constructives
+	  raise NoMethodError.
+	  Fixes [ruby-core:43009][Bug #6102]
+
 Thu Mar 28 18:14:41 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* tool/mkconfig.rb: reconstruct comma separated list values.  a
Index: ruby_1_9_3/ext/openssl/ossl_asn1.c
===================================================================
--- ruby_1_9_3/ext/openssl/ossl_asn1.c	(revision 39979)
+++ ruby_1_9_3/ext/openssl/ossl_asn1.c	(revision 39980)
@@ -149,11 +149,16 @@ num_to_asn1integer(VALUE obj, ASN1_INTEG https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/openssl/ossl_asn1.c#L149
 ASN1_INTEGER *
 num_to_asn1integer(VALUE obj, ASN1_INTEGER *ai)
 {
-    BIGNUM *bn = GetBNPtr(obj);
+    BIGNUM *bn;
+   
+    if (NIL_P(obj)) 
+	ossl_raise(rb_eTypeError, "Can't convert nil into Integer");
 
-    if (!(ai = BN_to_ASN1_INTEGER(bn, ai))) {
+    bn = GetBNPtr(obj);
+
+    if (!(ai = BN_to_ASN1_INTEGER(bn, ai)))
 	ossl_raise(eOSSLError, NULL);
-    }
+
     return ai;
 }
 #endif
@@ -219,6 +224,9 @@ static ID sivVALUE, sivTAG, sivTAG_CLASS https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/openssl/ossl_asn1.c#L224
 static ASN1_BOOLEAN
 obj_to_asn1bool(VALUE obj)
 {
+    if (NIL_P(obj))
+	ossl_raise(rb_eTypeError, "Can't convert nil into Boolean");
+
 #if OPENSSL_VERSION_NUMBER < 0x00907000L
      return RTEST(obj) ? 0xff : 0x100;
 #else
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 39979)
+++ ruby_1_9_3/version.h	(revision 39980)
@@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/version.h#L1
 #define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 397
+#define RUBY_PATCHLEVEL 398
 
 #define RUBY_RELEASE_DATE "2013-03-28"
 #define RUBY_RELEASE_YEAR 2013
Index: ruby_1_9_3/test/openssl/test_asn1.rb
===================================================================
--- ruby_1_9_3/test/openssl/test_asn1.rb	(revision 39979)
+++ ruby_1_9_3/test/openssl/test_asn1.rb	(revision 39980)
@@ -198,6 +198,18 @@ class  OpenSSL::TestASN1 < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/test/openssl/test_asn1.rb#L198
     encode_decode_test(OpenSSL::ASN1::Integer, [72, -127, -128, 128, -1, 0, 1, -(2**12345), 2**12345])
   end
 
+  def test_encode_nil
+    m = OpenSSL::ASN1
+    [ 
+      m::Boolean, m::Integer, m::BitString, m::OctetString,
+      m::ObjectId, m::Enumerated, m::UTF8String, m::UTCTime,
+      m::GeneralizedTime, m::Sequence, m::Set
+    ].each do |klass|
+      #Primitives raise TypeError, Constructives NoMethodError
+      assert_raise(TypeError, NoMethodError) { klass.send(:new, nil).to_der }
+    end
+  end
+
   def encode_decode_test(type, values)
     values.each do |v|
       assert_equal(v, OpenSSL::ASN1.decode(type.new(v).to_der).value)

Property changes on: ruby_1_9_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r35159


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]