aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-05-12 23:30:09 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-05-14 20:00:56 +0900
commit9fc7a2a1206d5bfe85dff9e01f8a102fb38d2153 (patch)
treef201d7e01bb935d09f43142d727b33611ab475b7 /ext/openssl
parentf2e3ad91380f799e1650c38b5bd6c24b7ed6fc5b (diff)
downloadruby-9fc7a2a1206d5bfe85dff9e01f8a102fb38d2153.tar.gz
ext/openssl: check argument type in OpenSSL::X509::Attribute#value=
The following code causes SEGV: OpenSSL::X509::Attribute.new("challengePassword", nil) * ext/openssl/ossl_x509attr.c (ossl_x509attr_set_value): check that the argument is an instance of OpenSSL::ASN1::Data, before ossl_asn1_get_asn1type(). * test/openssl/test_x509attr.rb: add tests
Diffstat (limited to 'ext/openssl')
-rw-r--r--ext/openssl/ossl_x509attr.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/ext/openssl/ossl_x509attr.c b/ext/openssl/ossl_x509attr.c
index d0f41c6bb8..be5f2dcf88 100644
--- a/ext/openssl/ossl_x509attr.c
+++ b/ext/openssl/ossl_x509attr.c
@@ -196,6 +196,7 @@ ossl_x509attr_set_value(VALUE self, VALUE value)
X509_ATTRIBUTE *attr;
ASN1_TYPE *a1type;
+ OSSL_Check_Kind(value, cASN1Data);
if(!(a1type = ossl_asn1_get_asn1type(value)))
ossl_raise(eASN1Error, "could not get ASN1_TYPE");
if(ASN1_TYPE_get(a1type) == V_ASN1_SEQUENCE){