]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Avoid mismatch between library and test crypto configuration 1437/head
authorAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Thu, 17 Sep 2020 17:14:58 +0000 (18:14 +0100)
committerAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Thu, 17 Sep 2020 17:14:58 +0000 (18:14 +0100)
I was investigating libarchive test failures on FreeBSD and it turns out
we get a reproducible SIGBUS for test_archive_m5, etc. Debugging this shows
that libarchive and the tests disagree when it comes to the definition of
archive_md5_ctx: libarchive assumes it's the OpenSSL type whereas the test
use the libmd type. The latter is not necessarily aligned enough to store
a pointer (16 bytes for CHERI RISC-V), so we were crashing when storing
EVP_MD_CTX* to an 8-byte-aligned archive_md5_ctx.

To avoid problems like this in the future, add a new macro to the config
header and use that to ensure that all configuration check macros have
been defined in archive_digest_private.h.

build/cmake/config.h.in
configure.ac
libarchive/archive_digest_private.h
libarchive/config_freebsd.h

index fcbd80c5a171553fc7dae4c360f01e21abc4cf7c..6d2fa746927c5934c531fe1858c65676f013c1b1 100644 (file)
@@ -1,4 +1,5 @@
 /* config.h.  Generated from build/cmake/config.h.in by cmake configure */
+#define __LIBARCHIVE_CONFIG_H_INCLUDED 1
 
 /*
  * Ensure we have C99-style int64_t, etc, all defined.
index fbb7b3c25bf4996c479c560b0258067393cca10d..65c889a2f2aade2d88e351186ff6eda8384349e4 100644 (file)
@@ -47,6 +47,8 @@ ARCHIVE_REVISION=$(( LIBARCHIVE_VERSION_N() % 1000 ))
 ARCHIVE_LIBTOOL_VERSION=$ARCHIVE_INTERFACE:$ARCHIVE_REVISION:$ARCHIVE_MINOR
 
 # Stick the version numbers into config.h
+AC_DEFINE([__LIBARCHIVE_CONFIG_H_INCLUDED], [1],
+       [Internal macro for sanity checks])
 AC_DEFINE([LIBARCHIVE_VERSION_STRING],"LIBARCHIVE_VERSION_S()",
        [Version number of libarchive])
 AC_DEFINE_UNQUOTED([LIBARCHIVE_VERSION_NUMBER],"LIBARCHIVE_VERSION_N()",
index 15312ee9a07a318beeeced967fb875ec5b8382d8..9b3bd6621bf302be14bd587bb2095f2f6c39ab97 100644 (file)
 #ifndef __LIBARCHIVE_BUILD
 #error This header is only to be used internally to libarchive.
 #endif
+#ifndef __LIBARCHIVE_CONFIG_H_INCLUDED
+#error "Should have include config.h first!"
+#endif
+
 /*
  * Crypto support in various Operating Systems:
  *
index f16fd3495ed5583ea594fe6088ab4f4dcee51f57..a05121c7836b0e10e7f8c57746d1e22b51f9b268 100644 (file)
@@ -24,6 +24,7 @@
  *
  * $FreeBSD$
  */
+#define __LIBARCHIVE_CONFIG_H_INCLUDED 1
 
 #include <osreldate.h>