summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-28 09:19:07 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-28 09:19:07 +0000
commitea764677c84d7407f213293ca07f0b926b9548d3 (patch)
treea561be9f1491a96099034f82eed8877c7a1097b9 /ext
parentb3093a85590fb3fa78e71f3306a927818f389123 (diff)
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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@39980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/openssl/ossl_asn1.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c
index 31c9c45f05..210ae5ca8b 100644
--- a/ext/openssl/ossl_asn1.c
+++ b/ext/openssl/ossl_asn1.c
@@ -149,11 +149,16 @@ num_to_asn1integer(VALUE obj, ASN1_INTEGER *ai)
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, sivTAGGING, sivINFINITE_LENGTH, sivUNU
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