summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrhe <rhe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-05 16:18:38 +0000
committerrhe <rhe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-05 16:18:38 +0000
commitc7b583a7440228f408789ce9bfe2205c5762156f (patch)
tree0a9080af7d6d141dff4ceeb7a7015e668aed2593
parent0a523ab20dfe5564b33d962eb5a470896c6521f2 (diff)
openssl: avoid d2i_ASN1_BOOLEAN()
* ext/openssl/ossl_asn1.c (decode_bool): Do the same thing as d2i_ASN1_BOOLEAN() does by ourselves. This function is removed in OpenSSL 1.1.0. [ruby-core:75225] [Feature #12324] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55288 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--ext/openssl/ossl_asn1.c13
2 files changed, 14 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index c2e87a607a..b8c5892d5c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Mon Jun 6 01:18:10 2016 Kazuki Yamaguchi <k@rhe.jp>
+
+ * ext/openssl/ossl_asn1.c (decode_bool): Do the same thing as
+ d2i_ASN1_BOOLEAN() does by ourselves. This function is removed in
+ OpenSSL 1.1.0.
+ [ruby-core:75225] [Feature #12324]
+
Mon Jun 6 00:34:16 2016 Kazuki Yamaguchi <k@rhe.jp>
* ext/openssl/extconf.rb: Check existence of accessor functions that
diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c
index 51f0475424..03822b5c26 100644
--- a/ext/openssl/ossl_asn1.c
+++ b/ext/openssl/ossl_asn1.c
@@ -357,14 +357,15 @@ obj_to_asn1derstr(VALUE obj)
static VALUE
decode_bool(unsigned char* der, long length)
{
- int val;
- const unsigned char *p;
+ const unsigned char *p = der;
- p = der;
- if((val = d2i_ASN1_BOOLEAN(NULL, &p, length)) < 0)
- ossl_raise(eASN1Error, NULL);
+ assert(length == 3);
+ if (*p++ != 1)
+ ossl_raise(eASN1Error, "not a boolean");
+ if (*p++ != 1)
+ ossl_raise(eASN1Error, "length is not 1");
- return val ? Qtrue : Qfalse;
+ return *p ? Qtrue : Qfalse;
}
static VALUE