aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto/c_src/engine.c
diff options
context:
space:
mode:
authorDoug Hogan <[email protected]>2019-01-03 20:32:43 -0800
committerDoug Hogan <[email protected]>2019-01-08 01:11:57 -0800
commit448cda0d1668a643f8bddf7b0d1c1615e6d952b7 (patch)
treea9a3e7b74bd4d18c61b33d20ba35f90687057136 /lib/crypto/c_src/engine.c
parentf46401d46f9ed331ff2a09bb6a99376707083c96 (diff)
downloadotp-448cda0d1668a643f8bddf7b0d1c1615e6d952b7.tar.gz
otp-448cda0d1668a643f8bddf7b0d1c1615e6d952b7.tar.bz2
otp-448cda0d1668a643f8bddf7b0d1c1615e6d952b7.zip
Revamp get_engine_and_key_id()
Diffstat (limited to 'lib/crypto/c_src/engine.c')
-rw-r--r--lib/crypto/c_src/engine.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/crypto/c_src/engine.c b/lib/crypto/c_src/engine.c
index 71552a0a89..95966508ec 100644
--- a/lib/crypto/c_src/engine.c
+++ b/lib/crypto/c_src/engine.c
@@ -49,16 +49,20 @@ int get_engine_and_key_id(ErlNifEnv *env, ERL_NIF_TERM key, char ** id, ENGINE *
struct engine_ctx *ctx;
ErlNifBinary key_id_bin;
- if (!enif_get_map_value(env, key, atom_engine, &engine_res) ||
- !enif_get_resource(env, engine_res, engine_ctx_rtype, (void**)&ctx) ||
- !enif_get_map_value(env, key, atom_key_id, &key_id_term) ||
- !enif_inspect_binary(env, key_id_term, &key_id_bin)) {
- return 0;
- }
- else {
- *e = ctx->engine;
- return zero_terminate(key_id_bin, id);
- }
+ if (!enif_get_map_value(env, key, atom_engine, &engine_res))
+ goto err;
+ if (!enif_get_resource(env, engine_res, engine_ctx_rtype, (void**)&ctx))
+ goto err;
+ if (!enif_get_map_value(env, key, atom_key_id, &key_id_term))
+ goto err;
+ if (!enif_inspect_binary(env, key_id_term, &key_id_bin))
+ goto err;
+
+ *e = ctx->engine;
+ return zero_terminate(key_id_bin, id);
+
+ err:
+ return 0;
}
char *get_key_password(ErlNifEnv *env, ERL_NIF_TERM key) {