From 076d526f522b096148b7b9843a3f839bccc3ba04 Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Fri, 8 Oct 2021 18:24:40 -0400 Subject: [PATCH 1/4] crypto: avoid double free Coverity scan reported a free after use and I think its right. Tweak to avoid double free. Signed-off-by: Michael Dawson --- src/crypto/crypto_util.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/crypto/crypto_util.h b/src/crypto/crypto_util.h index ac95612a0b1a85..8532c37e1e8203 100644 --- a/src/crypto/crypto_util.h +++ b/src/crypto/crypto_util.h @@ -550,9 +550,12 @@ struct EnginePointer { inline void reset(ENGINE* engine_ = nullptr, bool finish_on_exit_ = false) { if (engine != nullptr) { - if (finish_on_exit) + if (finish_on_exit) { + // this also does the equivalent of ENGINE_free ENGINE_finish(engine); - ENGINE_free(engine); + } else { + ENGINE_free(engine); + } } engine = engine_; finish_on_exit = finish_on_exit_; From 0d4301e77f9b185b6424256aff84835dfc942e94 Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Tue, 12 Oct 2021 09:19:56 -0400 Subject: [PATCH 2/4] Update src/crypto/crypto_util.h Co-authored-by: Luigi Pinca --- src/crypto/crypto_util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crypto/crypto_util.h b/src/crypto/crypto_util.h index 8532c37e1e8203..a1ddc857b4db8a 100644 --- a/src/crypto/crypto_util.h +++ b/src/crypto/crypto_util.h @@ -551,7 +551,7 @@ struct EnginePointer { inline void reset(ENGINE* engine_ = nullptr, bool finish_on_exit_ = false) { if (engine != nullptr) { if (finish_on_exit) { - // this also does the equivalent of ENGINE_free + // This also does the equivalent of ENGINE_free. ENGINE_finish(engine); } else { ENGINE_free(engine); From 8bad8589c14c775bafee01f86febdbc97f84eaf3 Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Thu, 14 Oct 2021 10:45:48 -0400 Subject: [PATCH 3/4] Update src/crypto/crypto_util.h Co-authored-by: Darshan Sen --- src/crypto/crypto_util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crypto/crypto_util.h b/src/crypto/crypto_util.h index a1ddc857b4db8a..43ccd37afd9b1f 100644 --- a/src/crypto/crypto_util.h +++ b/src/crypto/crypto_util.h @@ -552,7 +552,7 @@ struct EnginePointer { if (engine != nullptr) { if (finish_on_exit) { // This also does the equivalent of ENGINE_free. - ENGINE_finish(engine); + CHECK_EQ(ENGINE_finish(engine), 1); } else { ENGINE_free(engine); } From a04c34396f1f8a5f0742ebcfc7b299b0bec1c269 Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Thu, 14 Oct 2021 10:45:54 -0400 Subject: [PATCH 4/4] Update src/crypto/crypto_util.h Co-authored-by: Darshan Sen --- src/crypto/crypto_util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crypto/crypto_util.h b/src/crypto/crypto_util.h index 43ccd37afd9b1f..9606c29097dfc0 100644 --- a/src/crypto/crypto_util.h +++ b/src/crypto/crypto_util.h @@ -554,7 +554,7 @@ struct EnginePointer { // This also does the equivalent of ENGINE_free. CHECK_EQ(ENGINE_finish(engine), 1); } else { - ENGINE_free(engine); + CHECK_EQ(ENGINE_free(engine), 1); } } engine = engine_;