sys-apps/ipmitool: Fixed build against openssl-1.1
authorLars Wendler <polynomial-c@gentoo.org>
Wed, 13 Jun 2018 13:04:37 +0000 (15:04 +0200)
committerLars Wendler <polynomial-c@gentoo.org>
Wed, 13 Jun 2018 13:04:58 +0000 (15:04 +0200)
Closes: https://bugs.gentoo.org/592494
Package-Manager: Portage-2.3.40, Repoman-2.3.9

sys-apps/ipmitool/files/ipmitool-1.8.18-openssl-1.1.patch [new file with mode: 0644]
sys-apps/ipmitool/ipmitool-1.8.18-r1.ebuild

diff --git a/sys-apps/ipmitool/files/ipmitool-1.8.18-openssl-1.1.patch b/sys-apps/ipmitool/files/ipmitool-1.8.18-openssl-1.1.patch
new file mode 100644 (file)
index 0000000..9e5a876
--- /dev/null
@@ -0,0 +1,145 @@
+Taken from various upstream commits:
+
+https://github.com/ipmitool/ipmitool/commit/b57487e360916ab3eaa50aa6d021c73b6337a4a0
+https://github.com/ipmitool/ipmitool/commit/77fe5635037ebaf411cae46cf5045ca819b5c145
+https://github.com/ipmitool/ipmitool/commit/f004b4b7197fc83e7d47ec8cbcaefffa9a922717
+https://github.com/ipmitool/ipmitool/commit/f004b4b7197fc83e7d47ec8cbcaefffa9a922717
+
+--- ipmitool-1.8.18/src/plugins/lanplus/lanplus_crypt_impl.c
++++ ipmitool-1.8.18/src/plugins/lanplus/lanplus_crypt_impl.c
+@@ -164,11 +164,7 @@
+                                                       uint8_t       * output,
+                                                       uint32_t        * bytes_written)
+ {
+-      EVP_CIPHER_CTX ctx;
+-      EVP_CIPHER_CTX_init(&ctx);
+-      EVP_EncryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, key, iv);
+-      EVP_CIPHER_CTX_set_padding(&ctx, 0);
+-      
++      EVP_CIPHER_CTX *ctx = NULL;
+       *bytes_written = 0;
+@@ -182,6 +178,14 @@
+               printbuf(input, input_length, "encrypting this data");
+       }
++      ctx = EVP_CIPHER_CTX_new();
++      if (ctx == NULL) {
++              lprintf(LOG_DEBUG, "ERROR: EVP_CIPHER_CTX_new() failed");
++              return;
++      }
++      EVP_CIPHER_CTX_init(ctx);
++      EVP_EncryptInit_ex(ctx, EVP_aes_128_cbc(), NULL, key, iv);
++      EVP_CIPHER_CTX_set_padding(ctx, 0);
+       /*
+        * The default implementation adds a whole block of padding if the input
+@@ -191,28 +195,28 @@
+       assert((input_length % IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE) == 0);
+-      if(!EVP_EncryptUpdate(&ctx, output, (int *)bytes_written, input, input_length))
++      if(!EVP_EncryptUpdate(ctx, output, (int *)bytes_written, input, input_length))
+       {
+               /* Error */
+               *bytes_written = 0;
+-              return;
+       }
+       else
+       {
+               uint32_t tmplen;
+-              if(!EVP_EncryptFinal_ex(&ctx, output + *bytes_written, (int *)&tmplen))
++              if(!EVP_EncryptFinal_ex(ctx, output + *bytes_written, (int *)&tmplen))
+               {
++                      /* Error */
+                       *bytes_written = 0;
+-                      return; /* Error */
+               }
+               else
+               {
+                       /* Success */
+                       *bytes_written += tmplen;
+-                      EVP_CIPHER_CTX_cleanup(&ctx);
+               }
+       }
++      /* performs cleanup and free */
++      EVP_CIPHER_CTX_free(ctx);
+ }
+@@ -239,11 +243,7 @@
+                                                       uint8_t       * output,
+                                                       uint32_t        * bytes_written)
+ {
+-      EVP_CIPHER_CTX ctx;
+-      EVP_CIPHER_CTX_init(&ctx);
+-      EVP_DecryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, key, iv);
+-      EVP_CIPHER_CTX_set_padding(&ctx, 0);
+-
++      EVP_CIPHER_CTX *ctx = NULL;
+       if (verbose >= 5)
+       {
+@@ -252,12 +252,20 @@
+               printbuf(input, input_length, "decrypting this data");
+       }
+-
+       *bytes_written = 0;
+       if (input_length == 0)
+               return;
++      ctx = EVP_CIPHER_CTX_new();
++      if (ctx == NULL) {
++              lprintf(LOG_DEBUG, "ERROR: EVP_CIPHER_CTX_new() failed");
++              return;
++      }
++      EVP_CIPHER_CTX_init(ctx);
++      EVP_DecryptInit_ex(ctx, EVP_aes_128_cbc(), NULL, key, iv);
++      EVP_CIPHER_CTX_set_padding(ctx, 0);
++
+       /*
+        * The default implementation adds a whole block of padding if the input
+        * data is perfectly aligned.  We would like to keep that from happening.
+@@ -266,33 +274,33 @@
+       assert((input_length % IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE) == 0);
+-      if (!EVP_DecryptUpdate(&ctx, output, (int *)bytes_written, input, input_length))
++      if (!EVP_DecryptUpdate(ctx, output, (int *)bytes_written, input, input_length))
+       {
+               /* Error */
+               lprintf(LOG_DEBUG, "ERROR: decrypt update failed");
+               *bytes_written = 0;
+-              return;
+       }
+       else
+       {
+               uint32_t tmplen;
+-              if (!EVP_DecryptFinal_ex(&ctx, output + *bytes_written, (int *)&tmplen))
++              if (!EVP_DecryptFinal_ex(ctx, output + *bytes_written, (int *)&tmplen))
+               {
++                      /* Error */
+                       char buffer[1000];
+                       ERR_error_string(ERR_get_error(), buffer);
+                       lprintf(LOG_DEBUG, "the ERR error %s", buffer);
+                       lprintf(LOG_DEBUG, "ERROR: decrypt final failed");
+                       *bytes_written = 0;
+-                      return; /* Error */
+               }
+               else
+               {
+                       /* Success */
+                       *bytes_written += tmplen;
+-                      EVP_CIPHER_CTX_cleanup(&ctx);
+               }
+       }
++      /* performs cleanup and free */
++      EVP_CIPHER_CTX_free(ctx);
+       if (verbose >= 5)
+       {
index 62f5859016f1ca0bdeb0d37d0ef5434391a0cf47..6c26d8e0980c9400e8a18d201157e581b8298e76 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 1999-2016 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=6
@@ -29,6 +29,10 @@ DEPEND="${RDEPEND}
 # ipmitool CAN build against || ( sys-libs/openipmi sys-libs/freeipmi )
 # but it doesn't actually need either.
 
+PATCHES=(
+       "${FILESDIR}"/${P}-openssl-1.1.patch
+)
+
 src_prepare() {
        default
        [ -d "${S}"/debian ] && mv "${S}"/debian{,.package}