summaryrefslogtreecommitdiff
path: root/libarchive
diff options
context:
space:
mode:
authorTim Kientzle <kientzle@acm.org>2016-04-24 15:16:10 -0700
committerTim Kientzle <kientzle@acm.org>2016-04-24 15:16:10 -0700
commit11855358b842491568afd3e37203e4879c351c47 (patch)
treea747570127bdfac901a1ca835435ec60fd1ee6e1 /libarchive
parent2f637b08f8d2622b132050c34223c8b0f668eb21 (diff)
downloadlibarchive-11855358b842491568afd3e37203e4879c351c47.tar.gz
Ensure that cryptor, hmac, and xxhash always define at least one symbol. This prevents headaches with compilers and linkers that choke on empty object files.
Diffstat (limited to 'libarchive')
-rw-r--r--libarchive/archive_cryptor.c13
-rw-r--r--libarchive/archive_cryptor_private.h11
-rw-r--r--libarchive/archive_hmac.c14
-rw-r--r--libarchive/archive_hmac_private.h11
-rw-r--r--libarchive/xxhash.c20
5 files changed, 66 insertions, 3 deletions
diff --git a/libarchive/archive_cryptor.c b/libarchive/archive_cryptor.c
index f9615a64..0be30c60 100644
--- a/libarchive/archive_cryptor.c
+++ b/libarchive/archive_cryptor.c
@@ -31,6 +31,19 @@
#include "archive.h"
#include "archive_cryptor_private.h"
+/*
+ * On systems that do not support any recognized crypto libraries,
+ * this file will normally define no usable symbols.
+ *
+ * But some compilers and linkers choke on empty object files, so
+ * define a public symbol that will always exist. This could
+ * be removed someday if this file gains another always-present
+ * symbol definition.
+ */
+int __libarchive_cryptor_build_hack(void) {
+ return 0;
+}
+
#ifdef ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto
static int
diff --git a/libarchive/archive_cryptor_private.h b/libarchive/archive_cryptor_private.h
index f629bc13..37eaad36 100644
--- a/libarchive/archive_cryptor_private.h
+++ b/libarchive/archive_cryptor_private.h
@@ -30,6 +30,17 @@
#ifndef ARCHIVE_CRYPTOR_PRIVATE_H_INCLUDED
#define ARCHIVE_CRYPTOR_PRIVATE_H_INCLUDED
+/*
+ * On systems that do not support any recognized crypto libraries,
+ * the archive_cryptor.c file will normally define no usable symbols.
+ *
+ * But some compilers and linkers choke on empty object files, so
+ * define a public symbol that will always exist. This could
+ * be removed someday if this file gains another always-present
+ * symbol definition.
+ */
+int __libarchive_cryptor_build_hack(void);
+
#ifdef __APPLE__
# include <AvailabilityMacros.h>
# if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
diff --git a/libarchive/archive_hmac.c b/libarchive/archive_hmac.c
index 12fca456..7857c0ff 100644
--- a/libarchive/archive_hmac.c
+++ b/libarchive/archive_hmac.c
@@ -31,6 +31,20 @@
#include "archive.h"
#include "archive_hmac_private.h"
+/*
+ * On systems that do not support any recognized crypto libraries,
+ * the archive_hmac.c file is expected to define no usable symbols.
+ *
+ * But some compilers and linkers choke on empty object files, so
+ * define a public symbol that will always exist. This could
+ * be removed someday if this file gains another always-present
+ * symbol definition.
+ */
+int __libarchive_hmac_build_hack(void) {
+ return 0;
+}
+
+
#ifdef ARCHIVE_HMAC_USE_Apple_CommonCrypto
static int
diff --git a/libarchive/archive_hmac_private.h b/libarchive/archive_hmac_private.h
index 1f182d92..64de743c 100644
--- a/libarchive/archive_hmac_private.h
+++ b/libarchive/archive_hmac_private.h
@@ -30,6 +30,17 @@
#ifndef ARCHIVE_HMAC_PRIVATE_H_INCLUDED
#define ARCHIVE_HMAC_PRIVATE_H_INCLUDED
+/*
+ * On systems that do not support any recognized crypto libraries,
+ * the archive_hmac.c file is expected to define no usable symbols.
+ *
+ * But some compilers and linkers choke on empty object files, so
+ * define a public symbol that will always exist. This could
+ * be removed someday if this file gains another always-present
+ * symbol definition.
+ */
+int __libarchive_hmac_build_hack(void);
+
#ifdef __APPLE__
# include <AvailabilityMacros.h>
# if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
diff --git a/libarchive/xxhash.c b/libarchive/xxhash.c
index f7647a5e..7a55fc8e 100644
--- a/libarchive/xxhash.c
+++ b/libarchive/xxhash.c
@@ -29,8 +29,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
You can contact the author at :
- xxHash source repository : http://code.google.com/p/xxhash/
*/
+#include <stdlib.h>
+#include <string.h>
#include "archive_platform.h"
+#include "archive_xxhash.h"
+
#ifdef HAVE_LIBLZ4
/***************************************
@@ -83,11 +87,8 @@ You can contact the author at :
/***************************************
** Includes & Memory related functions
****************************************/
-#include "archive_xxhash.h"
-#include <stdlib.h>
#define XXH_malloc malloc
#define XXH_free free
-#include <string.h>
#define XXH_memcpy memcpy
@@ -497,4 +498,17 @@ struct archive_xxhash __archive_xxhash = {
XXH32_update,
XXH32_digest
};
+#else
+
+/*
+ * Define an empty version of the struct if we aren't using the LZ4 library.
+ */
+const
+struct archive_xxhash __archive_xxhash = {
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
#endif /* HAVE_LIBLZ4 */