summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-18 15:37:52 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-18 15:37:52 +0000
commitbd210ff16425ab92aef0ca4ac5a28061fac7c154 (patch)
tree328a46c315bbd6de1d2e5b364f36c38adb9690ae /ext
parent0181fbc4dee797bd704f1ae2b6827dd3caae64e2 (diff)
merge revision(s) 52556,52557: [Backport #10735]
* ext/openssl/ossl_pkey.c: Merge ruby/openssl@b9ea8ef [Bug #10735] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@52651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/openssl/ossl_pkey.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/ext/openssl/ossl_pkey.c b/ext/openssl/ossl_pkey.c
index aa9b046d38..ba9a019461 100644
--- a/ext/openssl/ossl_pkey.c
+++ b/ext/openssl/ossl_pkey.c
@@ -289,6 +289,7 @@ ossl_pkey_sign(VALUE self, VALUE digest, VALUE data)
EVP_MD_CTX ctx;
unsigned int buf_len;
VALUE str;
+ int result;
if (rb_funcall(self, id_private_q, 0, NULL) != Qtrue) {
ossl_raise(rb_eArgError, "Private key is needed.");
@@ -298,7 +299,9 @@ ossl_pkey_sign(VALUE self, VALUE digest, VALUE data)
StringValue(data);
EVP_SignUpdate(&ctx, RSTRING_PTR(data), RSTRING_LEN(data));
str = rb_str_new(0, EVP_PKEY_size(pkey)+16);
- if (!EVP_SignFinal(&ctx, (unsigned char *)RSTRING_PTR(str), &buf_len, pkey))
+ result = EVP_SignFinal(&ctx, (unsigned char *)RSTRING_PTR(str), &buf_len, pkey);
+ EVP_MD_CTX_cleanup(&ctx);
+ if (!result)
ossl_raise(ePKeyError, NULL);
assert((long)buf_len <= RSTRING_LEN(str));
rb_str_set_len(str, buf_len);