Skip to content

Commit d52549a

Browse files
authored
Merge pull request #531 from no6v/pkey-sign-option-type-check
OpenSSL::PKey::PKey#sign etc. with wrong type option causes SEGV
2 parents ee64d93 + ef23525 commit d52549a

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

ext/openssl/ossl_pkey.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ static VALUE
200200
pkey_ctx_apply_options0(VALUE args_v)
201201
{
202202
VALUE *args = (VALUE *)args_v;
203+
Check_Type(args[1], T_HASH);
203204

204205
rb_block_call(args[1], rb_intern("each"), 0, NULL,
205206
pkey_ctx_apply_options_i, args[0]);

test/openssl/test_pkey_rsa.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ def test_sign_verify_options
108108
salt_length: 20, mgf1_hash: "SHA1")
109109
# Defaults to PKCS #1 v1.5 padding => verification failure
110110
assert_equal false, key.verify("SHA256", sig_pss, data)
111+
112+
# option type check
113+
assert_raise_with_message(TypeError, /expected Hash/) {
114+
key.sign("SHA256", data, ["x"])
115+
}
111116
end
112117

113118
def test_sign_verify_raw

0 commit comments

Comments
 (0)