aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl/ossl_pkey.c
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-10-14 11:34:10 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-10-14 11:35:18 +0900
commit0be7f41c647f5754313b60b370f3804c8ee453e5 (patch)
treeaa7f5755adf6cb3f121fcff284057b07b5712cc8 /ext/openssl/ossl_pkey.c
parent56fe37fc8d785663f0f11246748fae752edb50b4 (diff)
downloadruby-openssl-0be7f41c647f5754313b60b370f3804c8ee453e5.tar.gz
pkey: tighten buffer size for signature
We allocate too large buffer for the generated signature. The resulting signature, or the RSA encryption result, should not be larger than the size returned by EVP_PKEY_size() (or, DSA_size(), RSA_size(), and ECDSA_size()).
Diffstat (limited to 'ext/openssl/ossl_pkey.c')
-rw-r--r--ext/openssl/ossl_pkey.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ext/openssl/ossl_pkey.c b/ext/openssl/ossl_pkey.c
index 2ce95b7c..7f22c0df 100644
--- a/ext/openssl/ossl_pkey.c
+++ b/ext/openssl/ossl_pkey.c
@@ -303,7 +303,7 @@ ossl_pkey_sign(VALUE self, VALUE digest, VALUE data)
pkey = GetPrivPKeyPtr(self);
md = GetDigestPtr(digest);
StringValue(data);
- str = rb_str_new(0, EVP_PKEY_size(pkey)+16);
+ str = rb_str_new(0, EVP_PKEY_size(pkey));
ctx = EVP_MD_CTX_new();
if (!ctx)