app-arch/unzip: fix false overlapped components detection on 32-bit systems
authorThomas Deutschmann <whissi@gentoo.org>
Wed, 25 Mar 2020 19:56:42 +0000 (20:56 +0100)
committerThomas Deutschmann <whissi@gentoo.org>
Wed, 25 Mar 2020 19:58:30 +0000 (20:58 +0100)
Closes: https://bugs.gentoo.org/698694
Package-Manager: Portage-2.3.94, Repoman-2.3.21
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
app-arch/unzip/files/unzip-6.0-fix-false-overlap-detection-on-32bit-systems.patch [new file with mode: 0644]
app-arch/unzip/unzip-6.0_p25-r1.ebuild [moved from app-arch/unzip/unzip-6.0_p25.ebuild with 96% similarity]

diff --git a/app-arch/unzip/files/unzip-6.0-fix-false-overlap-detection-on-32bit-systems.patch b/app-arch/unzip/files/unzip-6.0-fix-false-overlap-detection-on-32bit-systems.patch
new file mode 100644 (file)
index 0000000..ad6a157
--- /dev/null
@@ -0,0 +1,50 @@
+From 13f0260beae851f7d5dd96e9ef757d8d6d7daac1 Mon Sep 17 00:00:00 2001
+From: Mark Adler <madler@alumni.caltech.edu>
+Date: Sun, 9 Feb 2020 07:20:13 -0800
+Subject: [PATCH] Fix false overlapped components detection on 32-bit systems.
+
+32-bit systems with ZIP64_SUPPORT enabled could have different
+size types for zoff_t and zusz_t. That resulted in bad parameter
+passing to the bound tracking functions, itself due to the lack of
+use of C function prototypes in unzip. This commit assures that
+parameters are cast properly for those calls.
+
+This problem occurred only for ill-chosen make options, which give
+a 32-bit zoff_t. A proper build will result in a zoff_t of 64 bits,
+even on 32-bit systems.
+---
+ extract.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/extract.c b/extract.c
+index 1b73cb0..d9866f9 100644
+--- a/extract.c
++++ b/extract.c
+@@ -329,7 +329,7 @@ static ZCONST char Far OverlappedComponents[] =
+ /* A growable list of spans. */
+-typedef zoff_t bound_t;
++typedef zusz_t bound_t;
+ typedef struct {
+     bound_t beg;        /* start of the span */
+     bound_t end;        /* one past the end of the span */
+@@ -518,7 +518,8 @@ int extract_or_test_files(__G)    /* return PK-type error code */
+         return PK_MEM;
+     }
+     if ((G.extra_bytes != 0 &&
+-         cover_add((cover_t *)G.cover, 0, G.extra_bytes) != 0) ||
++         cover_add((cover_t *)G.cover,
++                   (bound_t)0, (bound_t)G.extra_bytes) != 0) ||
+         (G.ecrec.have_ecr64 &&
+          cover_add((cover_t *)G.cover, G.ecrec.ec64_start,
+                    G.ecrec.ec64_end) != 0) ||
+@@ -1216,7 +1217,7 @@ static int extract_or_test_entrylist(__G__ numchunk,
+         /* seek_zipf(__G__ pInfo->offset);  */
+         request = G.pInfo->offset + G.extra_bytes;
+-        if (cover_within((cover_t *)G.cover, request)) {
++        if (cover_within((cover_t *)G.cover, (bound_t)request)) {
+             Info(slide, 0x401, ((char *)slide,
+               LoadFarString(OverlappedComponents)));
+             return PK_BOMB;
similarity index 96%
rename from app-arch/unzip/unzip-6.0_p25.ebuild
rename to app-arch/unzip/unzip-6.0_p25-r1.ebuild
index b0f5ed79c0d8965aa7cfd57c9644537a95ac8a1f..b393dd2445e68378dfbb370c63bf29ed8c76eee2 100644 (file)
@@ -32,6 +32,7 @@ src_prepare() {
 
        eapply "${FILESDIR}"/${PN}-6.0-no-exec-stack.patch
        eapply "${FILESDIR}"/${PN}-6.0-format-security.patch
+       eapply "${FILESDIR}"/${PN}-6.0-fix-false-overlap-detection-on-32bit-systems.patch
        use natspec && eapply "${FILESDIR}/${PN}-6.0-natspec.patch" #275244
        sed -i -r \
                -e '/^CFLAGS/d' \