diff options
author | rhe <rhe@ruby-lang.org> | 2016-06-05 16:18:38 +0000 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-06-09 15:05:21 +0900 |
commit | 0b1e59f2c11b345ec344fe616c470a703fc079b6 (patch) | |
tree | 9cc251a7181d6b8e24cbdbd0f6c5b59a3ed781d6 /ext/openssl/ossl_asn1.c | |
parent | cad3226a06a1b6adab8da3a88c2f81cf50e17854 (diff) | |
download | ruby-openssl-0b1e59f2c11b345ec344fe616c470a703fc079b6.tar.gz |
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
Diffstat (limited to 'ext/openssl/ossl_asn1.c')
-rw-r--r-- | ext/openssl/ossl_asn1.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c index 51f04754..03822b5c 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 |