1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
From: Fabian Groffen <grobian@gentoo.org>
Date: Tue, 1 Jan 2019 18:00:08 +0100
Subject: Fix compatibility with openssl-1.0
Patch-Source: https://github.com/gentoo/gentoo/blob/dce914f2bbf52360f45c90d877857df3c4c2a353/app-arch/xar/files/xar-1.8-openssl-1.1.patch
--
lib/hash.c: fix compilation with OpenSSL-1.1+
EVP_MD_CTX has become an anonymous struct now, so can't allocate size
for it anymore.
Also add OpenSSL to configuration
---
xar/configure.ac | 10 ++++++++++
xar/lib/hash.c | 10 ++++++----
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/xar/configure.ac b/xar/configure.ac
index 3a36f42..c1f752b 100644
--- a/xar/configure.ac
+++ b/xar/configure.ac
@@ -319,6 +319,16 @@ if test "x${have_libxml2}" = "x0" ; then
AC_MSG_ERROR([Cannot build without libxml2])
fi
+dnl
+dnl Configure libcrypto (part of OpenSSL).
+dnl
+have_libcrypto="1"
+AC_CHECK_HEADERS([openssl/evp.h], , [have_libcrypto="0"])
+AC_CHECK_LIB([crypto], [OPENSSL_init_crypto], , [have_libcrypto="0"])
+if test "x${have_libcrypto}" = "x0" ; then
+ AC_MSG_ERROR([Cannot build without libcrypto (OpenSSL)])
+fi
+
dnl
dnl Configure libz.
dnl
diff --git a/xar/lib/hash.c b/xar/lib/hash.c
index 66876ad..cb4f6cf 100644
--- a/xar/lib/hash.c
+++ b/xar/lib/hash.c
@@ -97,7 +97,7 @@ struct __xar_hash_t {
#ifdef __APPLE__
CCDigestRef digest;
#else
- EVP_MD_CTX digest;
+ EVP_MD_CTX *digest;
const EVP_MD *type;
#endif
unsigned int length;
@@ -118,7 +118,8 @@ xar_hash_t xar_hash_new(const char *digest_name, void *context) {
#else
OpenSSL_add_all_digests();
HASH_CTX(hash)->type = EVP_get_digestbyname(digest_name);
- EVP_DigestInit(&HASH_CTX(hash)->digest, HASH_CTX(hash)->type);
+ HASH_CTX(hash)->digest = EVP_MD_CTX_create();
+ EVP_DigestInit(HASH_CTX(hash)->digest, HASH_CTX(hash)->type);
#endif
HASH_CTX(hash)->digest_name = strdup(digest_name);
@@ -138,7 +139,7 @@ void xar_hash_update(xar_hash_t hash, void *buffer, size_t nbyte) {
#ifdef __APPLE__
CCDigestUpdate(HASH_CTX(hash)->digest, buffer, nbyte);
#else
- EVP_DigestUpdate(&HASH_CTX(hash)->digest, buffer, nbyte);
+ EVP_DigestUpdate(HASH_CTX(hash)->digest, buffer, nbyte);
#endif
}
@@ -155,7 +156,8 @@ void *xar_hash_finish(xar_hash_t hash, size_t *nbyte) {
CCDigestFinal(HASH_CTX(hash)->digest, buffer);
CCDigestDestroy(HASH_CTX(hash)->digest);
#else
- EVP_DigestFinal(&HASH_CTX(hash)->digest, buffer, &HASH_CTX(hash)->length);
+ EVP_DigestFinal(HASH_CTX(hash)->digest, buffer, &HASH_CTX(hash)->length);
+ EVP_MD_CTX_destroy(HASH_CTX(hash)->digest);
#endif
*nbyte = HASH_CTX(hash)->length;
|