summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErlang/OTP <otp@erlang.org>2021-05-20 16:05:37 +0200
committerErlang/OTP <otp@erlang.org>2021-05-20 16:05:37 +0200
commit625b72a596f743915bee3b4556cbe00ca942f2f9 (patch)
treec4727acaa861b9a1845b20632bda16377fbe5d28
parentb41d3d067a1096bb05d3ddcdfc642bce3e5dda28 (diff)
parent5fa360d875041d7f66bc2be5b3a7462cad8a5217 (diff)
downloaderlang-625b72a596f743915bee3b4556cbe00ca942f2f9.tar.gz
Merge branch 'hans/crypto/fix_coredump/GH-4810/OTP-17391' into maint-24
* hans/crypto/fix_coredump/GH-4810/OTP-17391: crypto: Test fixed coredump if bad enc-flag crypto: Fixed coredump if bad enc-flag
-rw-r--r--lib/crypto/c_src/api_ng.c1
-rw-r--r--lib/crypto/test/crypto_SUITE.erl12
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/crypto/c_src/api_ng.c b/lib/crypto/c_src/api_ng.c
index 942d17482a..c2ae10f2ac 100644
--- a/lib/crypto/c_src/api_ng.c
+++ b/lib/crypto/c_src/api_ng.c
@@ -303,7 +303,6 @@ static int get_init_args(ErlNifEnv* env,
return 1;
err:
- if (ctx_res->ctx) EVP_CIPHER_CTX_free(ctx_res->ctx);
return 0;
}
diff --git a/lib/crypto/test/crypto_SUITE.erl b/lib/crypto/test/crypto_SUITE.erl
index 40b6ad46d6..033f6495eb 100644
--- a/lib/crypto/test/crypto_SUITE.erl
+++ b/lib/crypto/test/crypto_SUITE.erl
@@ -49,6 +49,8 @@
app/1,
appup/0,
appup/1,
+ bad_combo/1,
+ bad_key_length/1,
bad_cipher_name/1,
bad_generate_key_name/1,
bad_hash_name/1,
@@ -401,6 +403,8 @@ groups() ->
{no_rc2_cbc, [], [no_support]},
{no_rc4, [], [no_support]},
{api_errors, [], [api_errors_ecdh,
+ bad_combo,
+ bad_key_length,
bad_cipher_name,
bad_generate_key_name,
bad_hash_name,
@@ -4217,6 +4221,14 @@ api_errors_ecdh(Config) when is_list(Config) ->
end)()
).
+bad_combo(_Config) ->
+ ?chk_api_name(crypto:crypto_dyn_iv_init(des_ede3_cbc, <<>>, []),
+ error:_).
+
+bad_key_length(_Config) ->
+ ?chk_api_name(crypto:crypto_dyn_iv_init(des_ede3_cbc, <<1>>, true),
+ error:{error,{"api_ng.c",_},"Can't initialize context, key_length"}).
+
bad_cipher_name(_Config) ->
?chk_api_name(crypto:crypto_init(foobar, <<1:128>>, true),
error:{badarg,{"api_ng.c",_Line},"Unknown cipher"}).