diff --git a/misc/podman/rebuild-stubs/30-rebuild-stubs.sh b/misc/podman/rebuild-stubs/30-rebuild-stubs.sh index eb9bb675..c3adc235 100755 --- a/misc/podman/rebuild-stubs/30-rebuild-stubs.sh +++ b/misc/podman/rebuild-stubs/30-rebuild-stubs.sh @@ -27,6 +27,12 @@ fi podman run "${flags[@]}" "$image" bash -c $' set -ex; set -o pipefail +cd /home/upx/src/upx +# check whitespace +[[ -d .git ]] && bash ./misc/scripts/check_whitespace_git.sh +# rebuild docs +make -C doc clean all +# rebuild stubs cd /home/upx/src/upx/src/stub make maintainer-clean extra-clean git status . || true # make sure the stub files got deleted diff --git a/misc/podman/rebuild-stubs/Dockerfile b/misc/podman/rebuild-stubs/Dockerfile index 061f160f..bd938335 100644 --- a/misc/podman/rebuild-stubs/Dockerfile +++ b/misc/podman/rebuild-stubs/Dockerfile @@ -18,7 +18,7 @@ RUN dpkg --add-architecture i386 \ elfutils execstack fd-find file fish fzf g++ gawk gdb gojq ht htop hyperfine jq ksh \ libzstd-dev lsb-release lz4 lzip lzop minify mksh moreutils musl neovim ninja-build \ p7zip parallel patch patchelf patchutils pax-utils proot \ - python3 python3-pyasn1 python3-pycryptodome python3-yaml python3-zstd \ + python3 python3-pyasn1 python3-pycryptodome python3-pycurl python3-toml python3-yaml python3-zstd \ re2c ripgrep rsync screen universal-ctags unzip yash yq \ zip zlib1g-dev zoxide zsh zstd \ # extra packages for compiling with "gcc -m32" and "gcc -mx32": diff --git a/misc/podman/rebuild-stubs/packages.txt b/misc/podman/rebuild-stubs/packages.txt index 6890f335..b04cef02 100644 --- a/misc/podman/rebuild-stubs/packages.txt +++ b/misc/podman/rebuild-stubs/packages.txt @@ -314,6 +314,7 @@ ii python3-argcomplete 3.1.4-1 all ii python3-minimal 3.12.3-0ubuntu1 amd64 minimal subset of the Python language (default python3 version) ii python3-pyasn1 0.4.8-4 all ASN.1 library for Python (Python 3 module) ii python3-pycryptodome 3.20.0+dfsg-1 amd64 cryptographic Python library (Python 3) +ii python3-pycurl 7.45.3-1build2 amd64 Python bindings to libcurl (Python 3) ii python3-pyelftools 0.30-1 all pure-python3 library for parsing ELF and DWARF ii python3-toml 0.10.2-1 all library for Tom's Obvious, Minimal Language - Python 3.x ii python3-xmltodict 0.13.0-1 all Makes working with XML feel like you are working with JSON (Python 3) @@ -356,7 +357,7 @@ ii zstd 1.5.5+dfsg2-2build1 amd64 ||/ Name Version Architecture Description Packages sorted by Installed-Size: - 874050 ===== TOTAL (350 packages) + 874252 ===== TOTAL (351 packages) 72249 gcc-13-x86-64-linux-gnu amd64 37841 g++-13-x86-64-linux-gnu amd64 36493 cmake amd64 @@ -577,6 +578,7 @@ Packages sorted by Installed-Size: 208 libpam0g amd64 207 libuchardet0 amd64 206 proot amd64 + 202 python3-pycurl amd64 200 libselinux1 amd64 200 libnghttp2-14 amd64 199 execstack amd64 diff --git a/src/check/dt_check.cpp b/src/check/dt_check.cpp index dbeec6b9..8965751c 100644 --- a/src/check/dt_check.cpp +++ b/src/check/dt_check.cpp @@ -504,6 +504,7 @@ void upx_compiler_sanity_check(void) noexcept { COMPILE_TIME_ASSERT_ALIGNED1(upx_charptr_unit_type) COMPILE_TIME_ASSERT(sizeof(*((charptr) nullptr)) == 1) + // check UPX_VERSION_xxx { using upx::compile_time::mem_eq; using upx::compile_time::string_len; @@ -511,9 +512,15 @@ void upx_compiler_sanity_check(void) noexcept { static_assert(string_len(UPX_VERSION_YEAR) == 4); static_assert(string_len(UPX_VERSION_DATE_ISO) == 10); static_assert(string_len(UPX_VERSION_DATE) == 12 || string_len(UPX_VERSION_DATE) == 13); - static_assert(mem_eq(UPX_VERSION_STRING, UPX_VERSION_STRING4, 3)); - static_assert(mem_eq(UPX_VERSION_DATE_ISO, UPX_VERSION_YEAR, 4)); - static_assert(mem_eq(&UPX_VERSION_DATE[sizeof(UPX_VERSION_DATE) - 5], UPX_VERSION_YEAR, 4)); + static_assert(mem_eq(UPX_VERSION_STRING4, UPX_VERSION_STRING, 3)); + static_assert(mem_eq(UPX_VERSION_YEAR, UPX_VERSION_DATE_ISO, 4)); + static_assert(mem_eq(UPX_VERSION_YEAR, &UPX_VERSION_DATE[sizeof(UPX_VERSION_DATE) - 5], 4)); + char buf[16]; + constexpr long long v = UPX_VERSION_HEX; + upx_safe_snprintf(buf, sizeof(buf), "%lld.%lld.%lld", (v >> 16), (v >> 8) & 255, v & 255); + assert_noexcept(strcmp(buf, UPX_VERSION_STRING) == 0); + upx_safe_snprintf(buf, sizeof(buf), "%lld.%lld%lld", (v >> 16), (v >> 8) & 255, v & 255); + assert_noexcept(strcmp(buf, UPX_VERSION_STRING4) == 0); } if (gitrev[0]) { diff --git a/src/help.cpp b/src/help.cpp index 845df8e0..dbadd6ab 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -105,19 +105,17 @@ struct PackerNames final { explicit PackerNames() noexcept = default; ~PackerNames() noexcept = default; - static constexpr size_t MAX_NAMES = 64; - static constexpr size_t MAX_METHODS = 8; - static constexpr size_t MAX_FILTERS = 16; + static constexpr unsigned MAX_NAMES = 64; // arbitrary limit, increase as needed struct Entry { const char *fname; const char *sname; - size_t methods_count; - size_t filters_count; - unsigned methods[MAX_METHODS]; - unsigned filters[MAX_FILTERS]; + unsigned methods_count; + unsigned filters_count; + unsigned methods[PackerBase::MAX_METHODS]; + unsigned filters[PackerBase::MAX_FILTERS]; }; Entry names[MAX_NAMES]; - size_t names_count = 0; + unsigned names_count = 0; const Options *o = nullptr; void add(const PackerBase *pb) { @@ -129,14 +127,14 @@ struct PackerNames final { for (const int *m = pb->getCompressionMethods(M_ALL, 10); *m != M_END; m++) { if (*m >= 0) { assert_noexcept(Packer::isValidCompressionMethod(*m)); - assert_noexcept(e.methods_count < MAX_METHODS); + assert_noexcept(e.methods_count < PackerBase::MAX_METHODS); e.methods[e.methods_count++] = *m; } } for (const int *f = pb->getFilters(); f != nullptr && *f != FT_END; f++) { if (*f >= 0) { assert_noexcept(Filter::isValidFilter(*f)); - assert_noexcept(e.filters_count < MAX_FILTERS); + assert_noexcept(e.filters_count < PackerBase::MAX_FILTERS); e.filters[e.filters_count++] = *f; } } @@ -481,7 +479,7 @@ void show_version(bool one_line) { fprintf(f, "Copyright (C) 2015" "-2024 Meta Platforms, Inc. and affiliates\n"); #endif #if (WITH_BZIP2) - // see + // see vendor/bzip2/bzlib.h fprintf(f, "Copyright (C) 1996" "-2010 Julian Seward\n"); #endif #if !defined(DOCTEST_CONFIG_DISABLE) diff --git a/src/packer.cpp b/src/packer.cpp index aa7402a3..5c6cb502 100644 --- a/src/packer.cpp +++ b/src/packer.cpp @@ -1031,16 +1031,14 @@ void Packer::compressWithFilters(byte *i_ptr, assert(orig_ft.id == 0); // prepare methods and filters - constexpr int MAX_METHODS = 8; - constexpr int MAX_FILTERS = 16; int methods[MAX_METHODS]; int nmethods = prepareMethods(methods, ph.method, getCompressionMethods(M_ALL, ph.level)); - assert(nmethods > 0); - assert(nmethods < MAX_METHODS); + assert_noexcept(nmethods > 0); + assert_noexcept(nmethods < (int) MAX_METHODS); int filters[MAX_FILTERS]; int nfilters = prepareFilters(filters, filter_strategy, getFilters()); - assert(nfilters > 0); - assert(nfilters < MAX_FILTERS); + assert_noexcept(nfilters > 0); + assert_noexcept(nfilters < (int) MAX_FILTERS); #if 0 printf("compressWithFilters: m(%d):", nmethods); for (int i = 0; i < nmethods; i++) diff --git a/src/packer.h b/src/packer.h index fef568be..b675038c 100644 --- a/src/packer.h +++ b/src/packer.h @@ -76,6 +76,10 @@ public: virtual void doList() = 0; virtual void doFileInfo() = 0; + // arbitrary limits, increase as needed + static constexpr unsigned MAX_METHODS = 8; // for getCompressionMethods() + static constexpr unsigned MAX_FILTERS = 16; // for getFilters() + protected: InputFile *const fi; // reference union { // unnamed union diff --git a/src/stub/src/c/lzma_d_c.c b/src/stub/src/c/lzma_d_c.c index e3ef613d..e6412f15 100644 --- a/src/stub/src/c/lzma_d_c.c +++ b/src/stub/src/c/lzma_d_c.c @@ -94,8 +94,6 @@ ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(SizeT) >= 4) #if (ACC_ARCH_I086) # define char char __huge #elif (ACC_CC_WATCOMC) -#else -#define CLzmaDecoderState const CLzmaDecoderState #endif int LzmaDecodeProperties(CLzmaProperties *, const unsigned char *, int); int LzmaDecode(CLzmaDecoderState *, const unsigned char *, SizeT, SizeT *, unsigned char *, SizeT, SizeT *);