]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Ensure that cryptor, hmac, and xxhash always define at least one symbol. This preven...
authorTim Kientzle <kientzle@acm.org>
Sun, 24 Apr 2016 22:16:10 +0000 (15:16 -0700)
committerTim Kientzle <kientzle@acm.org>
Sun, 24 Apr 2016 22:16:10 +0000 (15:16 -0700)
libarchive/archive_cryptor.c
libarchive/archive_cryptor_private.h
libarchive/archive_hmac.c
libarchive/archive_hmac_private.h
libarchive/xxhash.c

index f9615a64ac98d77d195489ca802eb0e1fdbe9cdd..0be30c601a94b98895b53a629f07012a68f7998b 100644 (file)
 #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
index f629bc13b70d12c2039ccf53e533fac7ff3c610f..37eaad369dc77bcca9d9da74ae7f6900c81ecec2 100644 (file)
 #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
index 12fca4561a95a2fbe8b10025da9085e94b466432..7857c0ff35689394593310f0c8cca50bec5b0c74 100644 (file)
 #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
index 1f182d92b954009973665ec37ee4288014f2ee1d..64de743cb3293b92a9dc534ab4a88d93ed39fe7c 100644 (file)
 #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
index f7647a5e5fe2744293147b984488f4c13a38b2d5..7a55fc8ed81810f51d704294e07c10df95e1793b 100644 (file)
@@ -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 */