diff --git a/src/conf.h b/src/conf.h index 1adde8fe..cd9dffa1 100644 --- a/src/conf.h +++ b/src/conf.h @@ -111,6 +111,7 @@ ACC_COMPILE_TIME_ASSERT_HEADER((char)(-1) == 255) // -funsigned-char #undef snprintf #undef vsnprintf +#define HAVE_STDINT_H 1 #define ACC_WANT_ACC_INCD_H 1 #define ACC_WANT_ACC_INCE_H 1 #define ACC_WANT_ACC_LIB_H 1 @@ -738,7 +739,7 @@ unsigned membuffer_get_size(MemBuffer &mb); #include "util/xspan.h" -//#define DOCTEST_CONFIG_DISABLE +//#define DOCTEST_CONFIG_DISABLE 1 #include // util/dt_check.cpp diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp index 63f826e9..b647df12 100644 --- a/src/p_lx_elf.cpp +++ b/src/p_lx_elf.cpp @@ -6085,7 +6085,7 @@ Elf64_Sym const *PackLinuxElf64::elf_lookup(char const *name) const do { if (gashend <= hp) { char msg[120]; snprintf(msg, sizeof(msg), - "bad gnu_hash[%#zx] head=%u", + "bad gnu_hash[%#tx] head=%u", hp - hasharr, hhead); throwCantPack(msg); } diff --git a/src/util/dt_check.cpp b/src/util/dt_check.cpp index 0acaedea..3e3c7780 100644 --- a/src/util/dt_check.cpp +++ b/src/util/dt_check.cpp @@ -32,6 +32,10 @@ **************************************************************************/ bool upx_doctest_check(int argc, char **argv) { +#if defined(DOCTEST_CONFIG_DISABLE) + UNUSED(argc); + UNUSED(argv); +#else bool minimal = true; // only show failing tests bool duration = false; // show timings bool success = false; // show all tests @@ -66,6 +70,7 @@ bool upx_doctest_check(int argc, char **argv) { int r = context.run(); if (context.shouldExit() || r != 0) return false; +#endif return true; } diff --git a/src/util/dt_impl.cpp b/src/util/dt_impl.cpp index 219eb5ec..2c07ee7a 100644 --- a/src/util/dt_impl.cpp +++ b/src/util/dt_impl.cpp @@ -32,6 +32,11 @@ #define DOCTEST_CONFIG_IMPLEMENT #define DOCTEST_CONFIG_NO_MULTITHREADING #define DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS +#if defined(__MSDOS__) && defined(__DJGPP__) +#define DOCTEST_CONFIG_NO_POSIX_SIGNALS +#endif +#if !defined(DOCTEST_CONFIG_DISABLE) #include +#endif /* vim:set ts=4 sw=4 et: */ diff --git a/src/util/xspan.cpp b/src/util/xspan.cpp index 97c95834..a7b35352 100644 --- a/src/util/xspan.cpp +++ b/src/util/xspan.cpp @@ -480,6 +480,7 @@ TEST_CASE("Span constness") { // **************************************************************************/ +#if !defined(DOCTEST_CONFIG_DISABLE) namespace { int my_memcmp_v1(SPAN_P(const void) a, SPAN_0(const void) b, size_t n) { if (b == nullptr) @@ -499,6 +500,7 @@ int my_memcmp_v2(SPAN_P(const char) a, SPAN_0(const char) b, size_t n) { return memcmp(x, y, n); } } // namespace +#endif TEST_CASE("PtrOrSpan") { static const char buf[4] = {0, 1, 2, 3}; diff --git a/src/util/xspan_fwd.h b/src/util/xspan_fwd.h index 1c1f1684..6965cc57 100644 --- a/src/util/xspan_fwd.h +++ b/src/util/xspan_fwd.h @@ -283,7 +283,9 @@ inline C operator-(const C &a, const LE32 &v) { template typename std::enable_if::type upx_safe_strlen(const C &a) { // not fully checked, but can require at least 1 byte - return upx_safe_strlen(a.raw_bytes(1)); + upx_rsize_t len = upx_safe_strlen(a.raw_bytes(1)); + (void) a.raw_bytes(len + 1); // now can do a full check + return len; } #endif // UPX_VERSION_HEX