Skip to content

Commit

Permalink
Check if the option is an Hash in pkey_ctx_apply_options
Browse files Browse the repository at this point in the history
causes SEGV if it is an Array or something like that.
  • Loading branch information
no6v committed Aug 5, 2022
1 parent d36e6e5 commit 5584cd3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions ext/openssl/ossl_pkey.c
Expand Up @@ -209,6 +209,7 @@ pkey_ctx_apply_options0(VALUE args_v)
static void
pkey_ctx_apply_options(EVP_PKEY_CTX *ctx, VALUE options, int *state)
{
Check_Type(options, T_HASH);
VALUE args[2];
args[0] = (VALUE)ctx;
args[1] = options;
Expand Down
5 changes: 5 additions & 0 deletions test/openssl/test_pkey_rsa.rb
Expand Up @@ -108,6 +108,11 @@ def test_sign_verify_options
salt_length: 20, mgf1_hash: "SHA1")
# Defaults to PKCS #1 v1.5 padding => verification failure
assert_equal false, key.verify("SHA256", sig_pss, data)

# option type check
assert_raise_with_message(TypeError, /expected Hash/) {
key.sign("SHA256", data, ["x"])
}
end

def test_sign_verify_raw
Expand Down

0 comments on commit 5584cd3

Please sign in to comment.