summaryrefslogtreecommitdiffstats
path: root/ext/openssl/ossl_asn1.c
diff options
context:
space:
mode:
authoremboss <emboss@ruby-lang.org>2011-05-22 22:00:24 +0000
committeremboss <emboss@ruby-lang.org>2011-05-22 22:00:24 +0000
commit992c85a79d7f855d8232f31972f57702a4bbf919 (patch)
treee09fe6e6b4c883ae58499407ecbb1262e7d8c8fe /ext/openssl/ossl_asn1.c
parent6602e8e0ed32f9c95571495b6418ae54c7caa898 (diff)
downloadruby-openssl-history-992c85a79d7f855d8232f31972f57702a4bbf919.tar.gz
* 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
Diffstat (limited to 'ext/openssl/ossl_asn1.c')
-rw-r--r--ext/openssl/ossl_asn1.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c
index c6f1847..cd65195 100644
--- a/ext/openssl/ossl_asn1.c
+++ b/ext/openssl/ossl_asn1.c
@@ -1225,19 +1225,22 @@ ossl_asn1cons_to_der(VALUE self)
int found_prim = 0, seq_len;
long length;
unsigned char *p;
- VALUE value, str, inf_length, ary, example;
+ VALUE value, str, inf_length;
tn = NUM2INT(ossl_asn1_get_tag(self));
tc = ossl_asn1_tag_class(self);
inf_length = ossl_asn1_get_infinite_length(self);
if (inf_length == Qtrue) {
+ VALUE ary, example;
constructed = 2;
if (CLASS_OF(self) == cASN1Sequence ||
CLASS_OF(self) == cASN1Set) {
tag = ossl_asn1_default_tag(self);
}
- else { /*BIT_STRING OR OCTET_STRING*/
+ else { /* must be a constructive encoding of a primitive value */
ary = ossl_asn1_get_value(self);
+ if (!rb_obj_is_kind_of(ary, rb_cArray))
+ ossl_raise(eASN1Error, "Constructive value must be an Array");
/* Recursively descend until a primitive value is found.
The overall value of the entire constructed encoding
is of the type of the first primitive encoding to be