diff options
author | Hans Nilsson <[email protected]> | 2019-04-10 10:27:53 +0200 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2019-04-10 10:27:53 +0200 |
commit | f088a25bebcb74668dac21dc3b686fc2bea4502e (patch) | |
tree | 2220392aa7d4299c159d81b88d9d2d7b2e034099 | |
parent | 29b2edbe96bccabd7ee25c2722246010e4a77871 (diff) | |
parent | e3efa0b72246a85c3cd393014b6046dddfd271f0 (diff) | |
download | otp-f088a25bebcb74668dac21dc3b686fc2bea4502e.tar.gz otp-f088a25bebcb74668dac21dc3b686fc2bea4502e.tar.bz2 otp-f088a25bebcb74668dac21dc3b686fc2bea4502e.zip |
Merge branch 'hans/crypto/valgrind/OTP-15644'
* hans/crypto/valgrind/OTP-15644:
crypto: Remove compiler warning on an fprintf in the otp test engine
crypto: Fix valgrind error in api_ng.c ng_crypto_one_time for OpenSSL<1.0.1
-rw-r--r-- | lib/crypto/c_src/api_ng.c | 12 | ||||
-rw-r--r-- | lib/crypto/c_src/otp_test_engine.c | 2 |
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/crypto/c_src/api_ng.c b/lib/crypto/c_src/api_ng.c index 107723d2cb..3408ba1b88 100644 --- a/lib/crypto/c_src/api_ng.c +++ b/lib/crypto/c_src/api_ng.c @@ -522,6 +522,11 @@ ERL_NIF_TERM ng_crypto_one_time(ErlNifEnv* env, int argc, const ERL_NIF_TERM arg const struct cipher_type_t *cipherp; ERL_NIF_TERM ret; + ctx_res.ctx = NULL; +#if !defined(HAVE_EVP_AES_CTR) + ctx_res.env = NULL; +#endif + if (!get_init_args(env, &ctx_res, argv[0], argv[1], argv[2], argv[4], &cipherp, &ret)) goto ret; @@ -530,9 +535,16 @@ ERL_NIF_TERM ng_crypto_one_time(ErlNifEnv* env, int argc, const ERL_NIF_TERM arg ret: if (ctx_res.ctx) EVP_CIPHER_CTX_free(ctx_res.ctx); + +#if !defined(HAVE_EVP_AES_CTR) + if (ctx_res.env) + enif_free_env(ctx_res.env); +#endif + return ret; } + ERL_NIF_TERM ng_crypto_one_time_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) {/* (Cipher, Key, IVec, Data, Encrypt) % if no IV for the Cipher, set IVec = <<>> */ diff --git a/lib/crypto/c_src/otp_test_engine.c b/lib/crypto/c_src/otp_test_engine.c index 4a155becf8..c3bd9dfb55 100644 --- a/lib/crypto/c_src/otp_test_engine.c +++ b/lib/crypto/c_src/otp_test_engine.c @@ -160,7 +160,7 @@ static int test_engine_md5_update(EVP_MD_CTX *ctx,const void *data, size_t count static int test_engine_md5_final(EVP_MD_CTX *ctx,unsigned char *md) { #ifdef OLD - fprintf(stderr, "MD5 final size of EVP_MD: %lu\r\n", sizeof(EVP_MD)); + fprintf(stderr, "MD5 final size of EVP_MD: %lu\r\n", (unsigned long)sizeof(EVP_MD)); if (!MD5_Final(md, data(ctx))) goto err; |