From a44b1ab6ad91b2ad5780e67cae3065648c0a78a8 Mon Sep 17 00:00:00 2001 From: Max Rees Date: Sat, 21 Mar 2020 14:41:57 -0500 Subject: system/unzip: change upstream to Debian (#123) Debian's patches close several CVEs, including a few of which I wasn't even aware. They also include the patches we were already carrying: These were plucked directly from Debian so the names are the same: 10-unzip-handle-pkware-verify.patch 20-unzip-uidgid-fix.patch Our unzip-6.0-heap-overflow-infloop.patch is covered by Debian's: 14-cve-2015-7696.patch 15-cve-2015-7697.patch 16-fix-integer-underflow-csiz-decrypted.patch --- system/unzip/10-unzip-handle-pkware-verify.patch | 21 ----- system/unzip/20-unzip-uidgid-fix.patch | 29 ------ system/unzip/APKBUILD | 31 ++++-- system/unzip/unzip-6.0-heap-overflow-infloop.patch | 104 --------------------- 4 files changed, 24 insertions(+), 161 deletions(-) delete mode 100644 system/unzip/10-unzip-handle-pkware-verify.patch delete mode 100644 system/unzip/20-unzip-uidgid-fix.patch delete mode 100644 system/unzip/unzip-6.0-heap-overflow-infloop.patch diff --git a/system/unzip/10-unzip-handle-pkware-verify.patch b/system/unzip/10-unzip-handle-pkware-verify.patch deleted file mode 100644 index b373ce07d..000000000 --- a/system/unzip/10-unzip-handle-pkware-verify.patch +++ /dev/null @@ -1,21 +0,0 @@ -From: Steven Schweda -Subject: Handle the PKWare verification bit of internal attributes -Bug-Debian: http://bugs.debian.org/630078 -X-Debian-version: 6.0-5 - ---- a/process.c -+++ b/process.c -@@ -1729,6 +1729,13 @@ - else if (uO.L_flag > 1) /* let -LL force lower case for all names */ - G.pInfo->lcflag = 1; - -+ /* Handle the PKWare verification bit, bit 2 (0x0004) of internal -+ attributes. If this is set, then a verification checksum is in the -+ first 3 bytes of the external attributes. In this case all we can use -+ for setting file attributes is the last external attributes byte. */ -+ if (G.crec.internal_file_attributes & 0x0004) -+ G.crec.external_file_attributes &= (ulg)0xff; -+ - /* do Amigas (AMIGA_) also have volume labels? */ - if (IS_VOLID(G.crec.external_file_attributes) && - (G.pInfo->hostnum == FS_FAT_ || G.pInfo->hostnum == FS_HPFS_ || diff --git a/system/unzip/20-unzip-uidgid-fix.patch b/system/unzip/20-unzip-uidgid-fix.patch deleted file mode 100644 index 3a308990e..000000000 --- a/system/unzip/20-unzip-uidgid-fix.patch +++ /dev/null @@ -1,29 +0,0 @@ -From: sms -Subject: Restore uid and gid information when requested -Bug-Debian: http://bugs.debian.org/689212 -X-Debian-version: 6.0-8 - ---- a/process.c -+++ b/process.c -@@ -2904,7 +2904,7 @@ - #ifdef IZ_HAVE_UXUIDGID - if (eb_len >= EB_UX3_MINLEN - && z_uidgid != NULL -- && (*((EB_HEADSIZE + 0) + ef_buf) == 1) -+ && (*((EB_HEADSIZE + 0) + ef_buf) == 1)) - /* only know about version 1 */ - { - uch uid_size; -@@ -2916,10 +2916,10 @@ - flags &= ~0x0ff; /* ignore any previous UNIX field */ - - if ( read_ux3_value((EB_HEADSIZE + 2) + ef_buf, -- uid_size, z_uidgid[0]) -+ uid_size, &z_uidgid[0]) - && - read_ux3_value((EB_HEADSIZE + uid_size + 3) + ef_buf, -- gid_size, z_uidgid[1]) ) -+ gid_size, &z_uidgid[1]) ) - { - flags |= EB_UX2_VALID; /* signal success */ - } diff --git a/system/unzip/APKBUILD b/system/unzip/APKBUILD index e915966a0..ea8f7e6fa 100644 --- a/system/unzip/APKBUILD +++ b/system/unzip/APKBUILD @@ -4,7 +4,8 @@ pkgname=unzip pkgver=6.0 _pkgver=$(printf '%s' "$pkgver" | tr -d .) -pkgrel=3 +_debver=25 +pkgrel=4 pkgdesc="Extract PKZIP-compatible .zip files" url="http://www.info-zip.org/UnZip.html" arch="all" @@ -12,12 +13,30 @@ license="Info-ZIP" subpackages="$pkgname-doc" # normally ftp://ftp.info-zip.org/pub/infozip/src/$pkgname$_pkgver.zip source="$pkgname-$pkgver.tgz::https://distfiles.adelielinux.org/source/$pkgname$_pkgver.tgz - 10-unzip-handle-pkware-verify.patch - 20-unzip-uidgid-fix.patch - unzip-6.0-heap-overflow-infloop.patch + http://deb.debian.org/debian/pool/main/u/unzip/unzip_$pkgver-$_debver.debian.tar.xz " builddir="$srcdir/$pkgname$_pkgver" +# secfixes: +# 6.0-r4: +# - CVE-2014-8139 +# - CVE-2014-8140 +# - CVE-2014-8141 +# - CVE-2014-9636 +# - CVE-2014-9913 +# - CVE-2016-9844 +# - CVE-2018-18384 +# - CVE-2018-1000035 +# - CVE-2019-13232 + +prepare() { + default_prepare + while read -r i; do + msg "$i" + patch -p1 -i "../debian/patches/$i" + done < ../debian/patches/series +} + build() { make -f unix/Makefile \ CC="${CHOST}-gcc" \ @@ -38,6 +57,4 @@ package() { } sha512sums="0694e403ebc57b37218e00ec1a406cae5cc9c5b52b6798e0d4590840b6cdbf9ddc0d9471f67af783e960f8fa2e620394d51384257dca23d06bcd90224a80ce5d unzip-6.0.tgz -9d2914f22fb0075a2b6f72825c235f46eafd8d47b6fb6fcc8303fc69336e256b15923c002d2615bb6af733344c2315e4a8504d77bae301e10c11d4736faa2c81 10-unzip-handle-pkware-verify.patch -57699582e9056af0817dcb67f8db67e6a1ff8208c137fbebcf559429e5f12b471b75d7e1ef938e5bbb5416074a51ac7342e4ce8057f4bbdcb0bf079b8d7832af 20-unzip-uidgid-fix.patch -b1e3fac6a787828efaaef8ec7cc52e1573aea27a6f29830af37ec4ba8bcd2a6488c953ab10eee0561c78e82c7401833ef172bebee793405d93632ce788756301 unzip-6.0-heap-overflow-infloop.patch" +13c16db420fa4a34be3090a9acdd79b01320da40ac5aa89a9dfca03e64b914b28eb72aff3882d02a8197457bcb8eeb9473c998cf6920e511883c9289a949fb21 unzip_6.0-25.debian.tar.xz" diff --git a/system/unzip/unzip-6.0-heap-overflow-infloop.patch b/system/unzip/unzip-6.0-heap-overflow-infloop.patch deleted file mode 100644 index 160c512f9..000000000 --- a/system/unzip/unzip-6.0-heap-overflow-infloop.patch +++ /dev/null @@ -1,104 +0,0 @@ -From bdd4a0cecd745cb4825e4508b5bdf2579731086a Mon Sep 17 00:00:00 2001 -From: Petr Stodulka -Date: Mon, 14 Sep 2015 18:23:17 +0200 -Subject: [PATCH 1/3] upstream fix for heap overflow - -https://bugzilla.redhat.com/attachment.cgi?id=1073002 ---- - crypt.c | 12 +++++++++++- - 1 file changed, 11 insertions(+), 1 deletion(-) - -diff --git a/crypt.c b/crypt.c -index 784e411..a8975f2 100644 ---- a/crypt.c -+++ b/crypt.c -@@ -465,7 +465,17 @@ int decrypt(__G__ passwrd) - GLOBAL(pInfo->encrypted) = FALSE; - defer_leftover_input(__G); - for (n = 0; n < RAND_HEAD_LEN; n++) { -- b = NEXTBYTE; -+ /* 2012-11-23 SMS. (OUSPG report.) -+ * Quit early if compressed size < HEAD_LEN. The resulting -+ * error message ("unable to get password") could be improved, -+ * but it's better than trying to read nonexistent data, and -+ * then continuing with a negative G.csize. (See -+ * fileio.c:readbyte()). -+ */ -+ if ((b = NEXTBYTE) == (ush)EOF) -+ { -+ return PK_ERR; -+ } - h[n] = (uch)b; - Trace((stdout, " (%02x)", h[n])); - } --- -2.4.6 - - -From 4b48844661ff9569f2ecf582a387d46a5775b5d8 Mon Sep 17 00:00:00 2001 -From: Kamil Dudka -Date: Mon, 14 Sep 2015 18:24:56 +0200 -Subject: [PATCH 2/3] fix infinite loop when extracting empty bzip2 data - -Bug: https://sourceforge.net/p/infozip/patches/23/ ---- - extract.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/extract.c b/extract.c -index 7134bfe..29db027 100644 ---- a/extract.c -+++ b/extract.c -@@ -2733,6 +2733,12 @@ __GDEF - int repeated_buf_err; - bz_stream bstrm; - -+ if (G.incnt <= 0 && G.csize <= 0L) { -+ /* avoid an infinite loop */ -+ Trace((stderr, "UZbunzip2() got empty input\n")); -+ return 2; -+ } -+ - #if (defined(DLL) && !defined(NO_SLIDE_REDIR)) - if (G.redirect_slide) - wsize = G.redirect_size, redirSlide = G.redirect_buffer; --- -2.4.6 - - -From bd150334fb4084f5555a6be26b015a0671cb5b74 Mon Sep 17 00:00:00 2001 -From: Kamil Dudka -Date: Tue, 22 Sep 2015 18:52:23 +0200 -Subject: [PATCH 3/3] extract: prevent unsigned overflow on invalid input - -Suggested-by: Stefan Cornelius ---- - extract.c | 11 ++++++++++- - 1 file changed, 10 insertions(+), 1 deletion(-) - -diff --git a/extract.c b/extract.c -index 29db027..b9ae667 100644 ---- a/extract.c -+++ b/extract.c -@@ -1257,8 +1257,17 @@ static int extract_or_test_entrylist(__G__ numchunk, - if (G.lrec.compression_method == STORED) { - zusz_t csiz_decrypted = G.lrec.csize; - -- if (G.pInfo->encrypted) -+ if (G.pInfo->encrypted) { -+ if (csiz_decrypted <= 12) { -+ /* handle the error now to prevent unsigned overflow */ -+ Info(slide, 0x401, ((char *)slide, -+ LoadFarStringSmall(ErrUnzipNoFile), -+ LoadFarString(InvalidComprData), -+ LoadFarStringSmall2(Inflate))); -+ return PK_ERR; -+ } - csiz_decrypted -= 12; -+ } - if (G.lrec.ucsize != csiz_decrypted) { - Info(slide, 0x401, ((char *)slide, - LoadFarStringSmall2(WrnStorUCSizCSizDiff), --- -2.5.2 - -- cgit v1.2.3-60-g2f50