commit: 1bee2f710c80be4ff2815c28b447812ed364d4fe Author: Sam James <sam <AT> gentoo <DOT> org> AuthorDate: Fri Jul 25 05:35:26 2025 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Fri Jul 25 05:35:26 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1bee2f71
app-arch/advancecomp: fix unaligned access Closes: https://bugs.gentoo.org/959422 Signed-off-by: Sam James <sam <AT> gentoo.org> app-arch/advancecomp/advancecomp-2.6-r1.ebuild | 57 ++++++++++++++++++++++ .../files/advancecomp-2.6-unaligned-access.patch | 43 ++++++++++++++++ 2 files changed, 100 insertions(+) diff --git a/app-arch/advancecomp/advancecomp-2.6-r1.ebuild b/app-arch/advancecomp/advancecomp-2.6-r1.ebuild new file mode 100644 index 000000000000..bf032e7e0494 --- /dev/null +++ b/app-arch/advancecomp/advancecomp-2.6-r1.ebuild @@ -0,0 +1,57 @@ +# Copyright 1999-2025 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +DESCRIPTION="Recompress ZIP, PNG and MNG, considerably improving compression" +HOMEPAGE=" + https://www.advancemame.it/comp-readme.html + https://github.com/amadvance/advancecomp/ +" +SRC_URI=" + https://github.com/amadvance/advancecomp/releases/download/v${PV}/${P}.tar.gz +" + +LICENSE="GPL-2+ Apache-2.0 LGPL-2.1+ MIT" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ppc ~ppc64 ~riscv ~x86" + +RDEPEND=" + app-arch/bzip2:= + sys-libs/zlib:= +" +DEPEND=" + ${RDEPEND} +" + +PATCHES=( + "${FILESDIR}"/${PN}-2.6-unaligned-access.patch +) + +src_configure() { + local myconf=( + --enable-bzip2 + # (--disable-* arguments are mishandled) + # --disable-debug + # --disable-valgrind + ) + econf "${myconf[@]}" +} + +src_test() { + # Tests seem to rely on exact output: + # https://sourceforge.net/p/advancemame/bugs/270/ + #default + + # Do a smoke test given we can't run the real testsuite + cp "${DISTDIR}"/${P}.tar.gz "${T}" || die + local level + for level in -0 -1 -2 -3 -4 ; do + ./advdef -z ${level} "${T}"/${P}.tar.gz || die + done +} + +src_install() { + default + dodoc HISTORY +} diff --git a/app-arch/advancecomp/files/advancecomp-2.6-unaligned-access.patch b/app-arch/advancecomp/files/advancecomp-2.6-unaligned-access.patch new file mode 100644 index 000000000000..017b8080cb18 --- /dev/null +++ b/app-arch/advancecomp/files/advancecomp-2.6-unaligned-access.patch @@ -0,0 +1,43 @@ +https://github.com/amadvance/advancecomp/commit/916501836f61ad1beedd943f40ff6f324181fe1d +https://sourceforge.net/p/advancemame/bugs/311/ +https://bugs.gentoo.org/959422 + +From 916501836f61ad1beedd943f40ff6f324181fe1d Mon Sep 17 00:00:00 2001 +From: Andrea Mazzoleni <[email protected]> +Date: Mon, 7 Jul 2025 14:11:09 +0200 +Subject: [PATCH] Fix misaligned access in vectorized comparison by adding + runtime alignment checks + +--- + zopfli/lz77.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/zopfli/lz77.c b/zopfli/lz77.c +index 9df899d..adb3ee4 100644 +--- a/zopfli/lz77.c ++++ b/zopfli/lz77.c +@@ -24,6 +24,7 @@ Author: [email protected] (Jyrki Alakuijala) + #include <assert.h> + #include <stdio.h> + #include <stdlib.h> ++#include <stdint.h> + + void ZopfliInitLZ77Store(const unsigned char* data, ZopfliLZ77Store* store) { + store->size = 0; +@@ -299,13 +300,13 @@ static const unsigned char* GetMatch(const unsigned char* scan, + const unsigned char* end, + const unsigned char* safe_end) { + +- if (sizeof(size_t) == 8) { ++ if (sizeof(size_t) == 8 && ((uintptr_t)scan % 8 == 0) && ((uintptr_t)match % 8 == 0)) { + /* 8 checks at once per array bounds check (size_t is 64-bit). */ + while (scan < safe_end && *((size_t*)scan) == *((size_t*)match)) { + scan += 8; + match += 8; + } +- } else if (sizeof(unsigned int) == 4) { ++ } else if (sizeof(unsigned int) == 4 && ((uintptr_t)scan % 4 == 0) && ((uintptr_t)match % 4 == 0)) { + /* 4 checks at once per array bounds check (unsigned int is 32-bit). */ + while (scan < safe_end + && *((unsigned int*)scan) == *((unsigned int*)match)) { +
