summaryrefslogtreecommitdiff
path: root/ext/openssl/ossl_asn1.c
diff options
context:
space:
mode:
authornahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-26 08:17:01 +0000
committernahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-26 08:17:01 +0000
commit0522ffd51f03afb615fc70844e25905da31b96f8 (patch)
tree1db889bf8a8365555d04f3b06fa75c376d37049f /ext/openssl/ossl_asn1.c
parent12893215b5330dc74f30a0f9dff28b1a5463d25a (diff)
* ext/openssl/ossl_asn1.c (ossl_asn1_decode0): OpenSSL::ASN1.decode
should reject indefinite length primitive encodings as that is illegal. Patch by Martin Bosslet. See #4324. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl/ossl_asn1.c')
-rw-r--r--ext/openssl/ossl_asn1.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c
index b67decc..44c19b9 100644
--- a/ext/openssl/ossl_asn1.c
+++ b/ext/openssl/ossl_asn1.c
@@ -772,6 +772,9 @@ ossl_asn1_decode0(unsigned char **pp, long length, long *offset, long depth,
else value = ossl_asn1_decode0(&p, len, &off, depth+1, 0, yield);
}
else{
+ if ((j & 0x01) && (len == 0)) {
+ ossl_raise(eASN1Error, "Infinite length for primitive value");
+ }
value = rb_str_new((const char *)p, len);
p += len;
off += len;