|
| 1 | +diff --git a/configure.ac b/configure.ac |
| 2 | +index 3a36f42..fc53a55 100644 |
| 3 | +--- a/configure.ac |
| 4 | ++++ b/configure.ac |
| 5 | +@@ -319,6 +319,16 @@ if test "x${have_libxml2}" = "x0" ; then |
| 6 | + AC_MSG_ERROR([Cannot build without libxml2]) |
| 7 | + fi |
| 8 | + |
| 9 | ++dnl |
| 10 | ++dnl Configure libcrypto (part of OpenSSL). |
| 11 | ++dnl |
| 12 | ++have_libcrypto="1" |
| 13 | ++AC_CHECK_HEADERS([openssl/evp.h], , [have_libcrypto="0"]) |
| 14 | ++AC_CHECK_LIB([crypto], [OPENSSL_init_crypto], , [have_libcrypto="0"]) |
| 15 | ++if test "x${have_libcrypto}" = "x0" ; then |
| 16 | ++ AC_MSG_ERROR([Cannot build withotu libcrypto (OpenSSL)]) |
| 17 | ++fi |
| 18 | ++ |
| 19 | + dnl |
| 20 | + dnl Configure libz. |
| 21 | + dnl |
| 22 | +diff --git a/include/xar.h.in b/include/xar.h.in |
| 23 | +index 054b742..77f0cad 100644 |
| 24 | +--- a/include/xar.h.in |
| 25 | ++++ b/include/xar.h.in |
| 26 | +@@ -49,6 +49,9 @@ extern "C" { |
| 27 | + #include <sys/stat.h> |
| 28 | + |
| 29 | + #ifdef __APPLE__ |
| 30 | ++#include <AvailabilityMacros.h> |
| 31 | ++#endif |
| 32 | ++#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101200 |
| 33 | + #import <os/availability.h> |
| 34 | + #else |
| 35 | + #define API_DEPRECATED(...) |
| 36 | +diff --git a/lib/archive.h b/lib/archive.h |
| 37 | +index f926245..c1096b2 100644 |
| 38 | +--- a/lib/archive.h |
| 39 | ++++ b/lib/archive.h |
| 40 | +@@ -40,12 +40,12 @@ |
| 41 | + #define _XAR_ARCHIVE_H_ |
| 42 | + #include <zlib.h> |
| 43 | + #include <libxml/hash.h> |
| 44 | +-#ifdef __APPLE__ |
| 45 | ++/* #ifdef __APPLE__ |
| 46 | + #include <CommonCrypto/CommonDigest.h> |
| 47 | + #include <CommonCrypto/CommonDigestSPI.h> |
| 48 | +-#else |
| 49 | ++#else */ |
| 50 | + #include <openssl/evp.h> |
| 51 | +-#endif |
| 52 | ++/* #endif */ |
| 53 | + #include <sys/types.h> |
| 54 | + #include <sys/stat.h> |
| 55 | + #include "xar.h" |
| 56 | +diff --git a/lib/filetree.c b/lib/filetree.c |
| 57 | +index f31682a..6de7bdf 100644 |
| 58 | +--- a/lib/filetree.c |
| 59 | ++++ b/lib/filetree.c |
| 60 | +@@ -46,6 +46,7 @@ |
| 61 | + #include <libxml/xmlwriter.h> |
| 62 | + #include <libxml/xmlreader.h> |
| 63 | + #include <libxml/xmlstring.h> |
| 64 | ++#include <libxml/encoding.h> |
| 65 | + |
| 66 | + #ifndef HAVE_ASPRINTF |
| 67 | + #include "asprintf.h" |
| 68 | +@@ -752,7 +753,8 @@ int xar_file_equals_file(xar_file_t f1, xar_file_t f2) |
| 69 | + size_t fspath1_size = 0, fspath2_size = 0; |
| 70 | + size_t ns1_size = 0, ns2_size = 0; |
| 71 | + const struct __xar_file_t * child1 = NULL, * child2 = NULL; |
| 72 | +- const uint keys_to_ignore_count = 1; |
| 73 | ++ // const uint keys_to_ignore_count = 1; |
| 74 | ++ #define keys_to_ignore_count 1 |
| 75 | + char * keys_to_ignore[keys_to_ignore_count] = { "id" }; // ID is allowed ot mismatch |
| 76 | + |
| 77 | + // If the two pointers match, call it the same. |
| 78 | +diff --git a/lib/hash.c b/lib/hash.c |
| 79 | +index 66876ad..6e055da 100644 |
| 80 | +--- a/lib/hash.c |
| 81 | ++++ b/lib/hash.c |
| 82 | +@@ -41,12 +41,14 @@ |
| 83 | + #include <string.h> |
| 84 | + #include <sys/types.h> |
| 85 | + #include <zlib.h> |
| 86 | ++/* |
| 87 | + #ifdef __APPLE__ |
| 88 | + #include <CommonCrypto/CommonDigest.h> |
| 89 | + #include <CommonCrypto/CommonDigestSPI.h> |
| 90 | + #else |
| 91 | ++*/ |
| 92 | + #include <openssl/evp.h> |
| 93 | +-#endif |
| 94 | ++/* #endif */ |
| 95 | + |
| 96 | + #include "xar.h" |
| 97 | + #include "hash.h" |
| 98 | +@@ -57,7 +59,7 @@ |
| 99 | + |
| 100 | + |
| 101 | + #pragma mark Hash Wrapper Object |
| 102 | +- |
| 103 | ++/* |
| 104 | + #ifdef __APPLE__ |
| 105 | + |
| 106 | + CCDigestRef digestRef_from_name(const char* name, unsigned int *outHashSize) { |
| 107 | +@@ -89,17 +91,19 @@ CCDigestRef digestRef_from_name(const char* name, unsigned int *outHashSize) { |
| 108 | + return result; |
| 109 | + } |
| 110 | + #endif // __APPLE__ |
| 111 | +- |
| 112 | ++*/ |
| 113 | + |
| 114 | + struct __xar_hash_t { |
| 115 | + const char *digest_name; |
| 116 | + void *context; |
| 117 | ++/* |
| 118 | + #ifdef __APPLE__ |
| 119 | + CCDigestRef digest; |
| 120 | + #else |
| 121 | +- EVP_MD_CTX digest; |
| 122 | ++*/ |
| 123 | ++ EVP_MD_CTX *digest; |
| 124 | + const EVP_MD *type; |
| 125 | +-#endif |
| 126 | ++/* #endif */ |
| 127 | + unsigned int length; |
| 128 | + }; |
| 129 | + |
| 130 | +@@ -112,14 +116,16 @@ xar_hash_t xar_hash_new(const char *digest_name, void *context) { |
| 131 | + |
| 132 | + if( context ) |
| 133 | + HASH_CTX(hash)->context = context; |
| 134 | +- |
| 135 | ++/* |
| 136 | + #ifdef __APPLE__ |
| 137 | + HASH_CTX(hash)->digest = digestRef_from_name(digest_name, &HASH_CTX(hash)->length); |
| 138 | + #else |
| 139 | ++*/ |
| 140 | + OpenSSL_add_all_digests(); |
| 141 | + HASH_CTX(hash)->type = EVP_get_digestbyname(digest_name); |
| 142 | +- EVP_DigestInit(&HASH_CTX(hash)->digest, HASH_CTX(hash)->type); |
| 143 | +-#endif |
| 144 | ++ HASH_CTX(hash)->digest = EVP_MD_CTX_create(); |
| 145 | ++ EVP_DigestInit(HASH_CTX(hash)->digest, HASH_CTX(hash)->type); |
| 146 | ++/* #endif */ |
| 147 | + |
| 148 | + HASH_CTX(hash)->digest_name = strdup(digest_name); |
| 149 | + |
| 150 | +@@ -135,28 +141,34 @@ const char *xar_hash_get_digest_name(xar_hash_t hash) { |
| 151 | + } |
| 152 | + |
| 153 | + void xar_hash_update(xar_hash_t hash, void *buffer, size_t nbyte) { |
| 154 | ++/* |
| 155 | + #ifdef __APPLE__ |
| 156 | + CCDigestUpdate(HASH_CTX(hash)->digest, buffer, nbyte); |
| 157 | + #else |
| 158 | +- EVP_DigestUpdate(&HASH_CTX(hash)->digest, buffer, nbyte); |
| 159 | +-#endif |
| 160 | ++*/ |
| 161 | ++ EVP_DigestUpdate(HASH_CTX(hash)->digest, buffer, nbyte); |
| 162 | ++/* #endif */ |
| 163 | + } |
| 164 | + |
| 165 | + void *xar_hash_finish(xar_hash_t hash, size_t *nbyte) { |
| 166 | ++/* |
| 167 | + #ifdef __APPLE__ |
| 168 | + void *buffer = calloc(1, CC_SHA512_DIGEST_LENGTH); // current biggest digest size This is what OpenSSL uses |
| 169 | + #else |
| 170 | ++*/ |
| 171 | + void *buffer = calloc(1, EVP_MAX_MD_SIZE); |
| 172 | +-#endif |
| 173 | ++/* #endif */ |
| 174 | + if( ! buffer ) |
| 175 | + return NULL; |
| 176 | +- |
| 177 | ++/* |
| 178 | + #ifdef __APPLE__ |
| 179 | + CCDigestFinal(HASH_CTX(hash)->digest, buffer); |
| 180 | + CCDigestDestroy(HASH_CTX(hash)->digest); |
| 181 | + #else |
| 182 | +- EVP_DigestFinal(&HASH_CTX(hash)->digest, buffer, &HASH_CTX(hash)->length); |
| 183 | +-#endif |
| 184 | ++*/ |
| 185 | ++ EVP_DigestFinal(HASH_CTX(hash)->digest, buffer, &HASH_CTX(hash)->length); |
| 186 | ++ EVP_MD_CTX_destroy(HASH_CTX(hash)->digest); |
| 187 | ++/* #endif */ |
| 188 | + |
| 189 | + *nbyte = HASH_CTX(hash)->length; |
| 190 | + free((void *)HASH_CTX(hash)->digest_name); |
| 191 | +diff --git a/lib/linuxattr.c b/lib/linuxattr.c |
| 192 | +index 0fec2bb..58ee6a8 100644 |
| 193 | +--- a/lib/linuxattr.c |
| 194 | ++++ b/lib/linuxattr.c |
| 195 | +@@ -226,7 +226,7 @@ int32_t xar_linuxattr_extract(xar_t x, xar_file_t f, const char* file, char *buf |
| 196 | + if( statfs(file, &sfs) != 0 ) { |
| 197 | + char *tmp, *bname; |
| 198 | + tmp = strdup(file); |
| 199 | +- bname = safe_dirname(tmp); |
| 200 | ++ bname = xar_safe_dirname(tmp); |
| 201 | + statfs(bname, &sfs); |
| 202 | + free(tmp); |
| 203 | + free(bname); |
| 204 | +diff --git a/src/xar.c b/src/xar.c |
| 205 | +index 9977e8a..4e01f4d 100644 |
| 206 | +--- a/src/xar.c |
| 207 | ++++ b/src/xar.c |
| 208 | +@@ -51,7 +51,7 @@ |
| 209 | + #include <time.h> |
| 210 | + #include "xar_internal.h" |
| 211 | + #include "config.h" |
| 212 | +-#include "filetree.h" |
| 213 | ++#include "../lib/filetree.h" |
| 214 | + #include "util.h" |
| 215 | + #define SYMBOLIC 1 |
| 216 | + #define NUMERIC 2 |
0 commit comments