From 7d6529a415457ccfc912d6b8ddbac327516ee5d5 Mon Sep 17 00:00:00 2001 From: emboss Date: Sun, 22 May 2011 22:00:24 +0000 Subject: * ext/openssl/ossl_asn1.c: Forbid Constructives whose value is not an Array to prevent segfault. Added test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/openssl/test_asn1.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/openssl') diff --git a/test/openssl/test_asn1.rb b/test/openssl/test_asn1.rb index 94083f86e4..0122e0fdcb 100644 --- a/test/openssl/test_asn1.rb +++ b/test/openssl/test_asn1.rb @@ -254,6 +254,18 @@ class OpenSSL::TestASN1 < Test::Unit::TestCase end end + def test_cons_without_array_forbidden + assert_raise(OpenSSL::ASN1::ASN1Error) do + val = OpenSSL::ASN1::OctetString.new('a') + cons = OpenSSL::ASN1::Constructive.new(val, + OpenSSL::ASN1::OCTET_STRING, + nil, + :UNIVERSAL) + cons.infinite_length = true + cons.to_der + end + end + def test_seq_infinite_length begin content = [ OpenSSL::ASN1::Null.new(nil), -- cgit v1.2.3