1From 72df3eadb27161a292f35b1d97178f70f41e50f6 Mon Sep 17 00:00:00 2001 2From: Zdenek Styblik <stybla@turnovfree.net> 3Date: Sun, 12 Mar 2017 14:00:35 +0100 4Subject: [PATCH] ID:480 - ipmitool coredumps in EVP_CIPHER_CTX_init 5 6IPMI tool coredumps due to changes introduced in ID:461. This shouldn't be 7surprise as a NULL pointer is passed to init. Commit addresses this issue by 8calling EVP_CIPHER_CTX_new() instead of EVP_CIPHER_CTX_init(), which is 9deprecated, and by checking return value of call to former function. 10 11Upstream: https://github.com/ipmitool/ipmitool/commit/f004b4b7197fc83e7d47ec8cbcaefffa9a922717 12 13Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com> 14--- 15 src/plugins/lanplus/lanplus_crypt_impl.c | 14 ++++++++++---- 16 1 file changed, 10 insertions(+), 4 deletions(-) 17 18diff --git a/src/plugins/lanplus/lanplus_crypt_impl.c b/src/plugins/lanplus/lanplus_crypt_impl.c 19index d12d0e3..0e330c1 100644 20--- a/src/plugins/lanplus/lanplus_crypt_impl.c 21+++ b/src/plugins/lanplus/lanplus_crypt_impl.c 22@@ -165,10 +165,13 @@ lanplus_encrypt_aes_cbc_128(const uint8_t * iv, 23 uint32_t * bytes_written) 24 { 25 EVP_CIPHER_CTX *ctx = NULL; 26- EVP_CIPHER_CTX_init(ctx); 27+ ctx = EVP_CIPHER_CTX_new(); 28+ if (ctx == NULL) { 29+ *bytes_written = 0; 30+ return; 31+ } 32 EVP_EncryptInit_ex(ctx, EVP_aes_128_cbc(), NULL, key, iv); 33 EVP_CIPHER_CTX_set_padding(ctx, 0); 34- 35 36 *bytes_written = 0; 37 38@@ -240,11 +243,14 @@ lanplus_decrypt_aes_cbc_128(const uint8_t * iv, 39 uint32_t * bytes_written) 40 { 41 EVP_CIPHER_CTX *ctx = NULL; 42- EVP_CIPHER_CTX_init(ctx); 43+ ctx = EVP_CIPHER_CTX_new(); 44+ if (ctx == NULL) { 45+ *bytes_written = 0; 46+ return; 47+ } 48 EVP_DecryptInit_ex(ctx, EVP_aes_128_cbc(), NULL, key, iv); 49 EVP_CIPHER_CTX_set_padding(ctx, 0); 50 51- 52 if (verbose >= 5) 53 { 54 printbuf(iv, 16, "decrypting with this IV"); 55-- 561.9.1 57 58