commit 8592fc9
hovercats
·
2024-04-12 06:42:19 +0000 UTC
parent 1ad9aa4
unzip: use patches from alpine instead we also dont need bzip2 to build.
43 files changed,
+874,
-2066
+4,
-7
1@@ -1,13 +1,12 @@
2 #!/bin/sh -e
3
4-while read -r p; do
5- patch -p1 < "$p"
6-done < series
7+for p in *.patch; do
8+ patch -p1 < "$p"
9+done
10
11 export DESTDIR="$1"
12-export LDFLAGS="$LDFLAGS -static -L/src/oakiss/out/usr/bzip2"
13+export LDFLAGS="$LDFLAGS -static"
14 export CFLAGS="$CFLAGS \
15- -I/src/oakiss/usr/bzip2/src \
16 -D_FILE_OFFSET_BITS=64 \
17 -DWILD_STOP_AT_DIR \
18 -DLARGE_FILE_SUPPORT \
19@@ -16,11 +15,9 @@ export CFLAGS="$CFLAGS \
20 -DUTF8_MAYBE_NATIVE \
21 -DNO_LCHMOD \
22 -LDDATE_FORMAT=DF_YMD \
23- -DUSE_BZIP2 \
24 -DNATIVE"
25
26 make \
27- D_USE_BZ2=-DUSE_BZIP2 L_BZ2=-lbz2 \
28 LF2="$LDFLAGS" CF="$CFLAGS $CPPFLAGS -I." \
29 prefix="$1/" \
30 -f unix/Makefile unzips
+20,
-23
1@@ -1,32 +1,29 @@
2 5969810311361d686f6408091d60d0a36bf29f1abfae05831be9c42e69aaf67f6f
3-39546eeb15e841aed165741093c0896d31f35ac38024dfa3960f0d5bb47997ebef
4-e13b7cbb6e5005eaeb5147c189b8f93beded83d314eeba08a6cc454fc43ffc44d2
5-5fdc4d182ad2d78462ca09e87de943b70aa063048d9d3768decf5e9f2f5a96b7c4
6-0036e591b726d54ce562f609f9d74713449278dab9040c95c4dbcbd9ca30ea915f
7-3715bf8ac1e3ff56082c6b431868bce7938d64bd25efc033814d7a67d66f9a6199
8-c17fa198734ff19d78410f2c334a11977a5cee98e05a75fe227c41ab1cfc33a950
9-4d169d70763fd28d8e1185481fc46fbe6ef640227d4b02a91770a595aaeefd02a5
10-6ff406487a846aa3222dae6fa9b95df36a54ace3047a150a70217c92e96f28d130
11-440ac6b17647bcc39765dc776a18b922d759bc346f5d0be8807188a43ed4c5a07b
12-df311a6c578ce88d750473ca2113bb9d87ce0f036cf1c101f602e17c67cc74b8ac
13-0b4b8e3965fffb111ccb82cad1a278675167d0f47aa35549d9fcbb634e93fd5575
14-f9cb4800cea71b4b2cbb1a1adf05e9e3f33c7c1394073e2e545c438d60300ec683
15-f584d7caffee134588c4008c0bb269b56b885a6779db4e82913c44dd6b35ef5f1e
16+14a524e4b8fa0576c4d4a46a1b39cb9d783154e631270095497c6eddfd42e74e89
17+f9d787008b7fefce52dc2b2d1ab306d11ffb10ad948125f2d3e4854ed443f92151
18+0a109f191c29e67e85d9dd00d3d68e1cae3bd24db5cd2ecf8758ab977bf9aa61a8
19+cae7141a54c8ce8a6080385391bda61e9352b1ed060e19b4a1107322491ed5ce48
20+3ba49afc6bc0e2856c2fb542372fc9d01d73c6ebf90b42bce8c195dce4f6ea60bb
21+a86fc891e61383eb2d3bfeb6f745a8898fe6bde7988065a6341aca451d5c56c332
22+a0ae032ad29c4a55b08a1d70251483b1bf26744777251295d571bdd3f9aed752f2
23+496299e7e55a8ee8ddfaaf060880c4edf55cde980a781eefbc064527e9499464e2
24+dd7b45cc908ba296607be0f25d3c9858a78bdc76c1aa03bfd8faba64eb99f946e0
25+deb35954bd14c41feca4630675b218d2760c0a72c2a583ad34de46f9b6fdb439f9
26+40e23490d4012a3d60faf51f61d5aace88555c3e4b88859b918ed2822bf727392d
27 2bac1b5b7039eaf8e5bcbf2d15b4c096a70b57ee7d61e8e14d0809df0090b10dc2
28-4dbcf9da1545f94a279d11a513f6febfb1d6d88d11100b7e28d2fefd6fffe9d05e
29+764205d76dc3d959efe7cd221cde896383d6d88f8ac588505ec21423a49df45dcc
30+5f3ba78d33ee7012cebb7702609e6360feed808c8a1d8bf8545348c4736e6f7c97
31+80aae983bda3cd6f1aab6a1b5f0891bbac4c3310fe2628194ae12847bf0303e8d3
32+eb58b94d1cc9f93a3e24a8652e6636d2929b710e077fcb8bd548e69cf1fd37582c
33 ec11baa02294b90c915300e209ae8f8747cc0ba14c54dc543f125dfd7a73f3c430
34-9cfe62e834de2d2513bd820ef84db55a7911188640813cd41cc164768e24ad509b
35 9871056e67f47ce9698b5bb50e8f65cf2e750a4f6c6af53304df1f4c40ebfbc77d
36 22be381e9e86b37282920418d14265d027ea434fad79b952482d409db3eec61470
37-9361c0f0ae89fa398c998662a15468feb0d035789b93aafc500898fdac00801a3b
38-ee4f8f10a83d1a23bfd35fbdefb97ec927383c2ba0105c28af8497964cef585f7c
39-8f53b98ad3d0d3601395c77150597fefabfdcb9d3a4f3b7e7d5f61471446fa2403
40-46816b2fd0c0121d3ef4662b9fc6531b88e1eed9007cf3c9c248c58a15c4b3b318
41 62eada60854366ff9db91fcf5d1450e28205faca989156adda1fe771a690821a89
42-6299ee334b4fe591f7c03830284f372265fec966d4b8436b0bfe08d6ae175d55f7
43-6be08aed32aea14744aba5adec840ecfb6721fecea784807ad4c4179832aa6ece3
44-da70d8638d7f933f1ad626fa6b6683dc50e0f9ec10db1ba446ca1b9b22783e5c70
45-4230500331de2ec2a090ea5ec3865afdc29b14691a5623e880add75e510ce17052
46+02db5a813642fc9c0cef6621b0bc17ea7899d618d3b6ae70891bbf63a7d3ac64fe
47 1c752da7d554901b29f43aaeb427776359dc4cc4b378e454b29dee26cb64ef3154
48 92ae3240adee386963fa34241435c9955aedc3e37203752ec37cb1a5d36dd87ddf
49 6abdb144fbdaa1cf3c498c7c71ea6ca317f0326d36fb1e4c0d3096650d0d8fb783
50+0e8b5dceeab1d0e054374abaab6d63edea4dee180d9167a7333d550ed42341f97d
51+5333cf5ef9e3a8a952b9fb0861665c5ee32ced7cdfbab52f4a170c1d3702ff3bbc
52+aed0b9882b97feac1d61504ad2e49585d70bae438d9498c028498422a7217601b2
53+885605de5f2c59ad6508544cf7d9e97a369dbed6ec7a7ca387ef2837166f08ed20
1@@ -0,0 +1,14 @@
2+From: Santiago Vila <sanvila@debian.org>
3+Subject: zipinfo.c: Do not crash when hostver byte is >= 100
4+
5+--- a/zipinfo.c
6++++ b/zipinfo.c
7+@@ -2114,7 +2114,7 @@
8+ else
9+ attribs[9] = (xattr & UNX_ISVTX)? 'T' : '-'; /* T==undefined */
10+
11+- sprintf(&attribs[12], "%u.%u", hostver/10, hostver%10);
12++ sprintf(&attribs[11], "%2u.%u", hostver/10, hostver%10);
13+ break;
14+
15+ } /* end switch (hostnum: external attributes format) */
1@@ -0,0 +1,21 @@
2+From: Steven Schweda
3+Subject: Handle the PKWare verification bit of internal attributes
4+Bug-Debian: http://bugs.debian.org/630078
5+X-Debian-version: 6.0-5
6+
7+--- a/process.c
8++++ b/process.c
9+@@ -1729,6 +1729,13 @@
10+ else if (uO.L_flag > 1) /* let -LL force lower case for all names */
11+ G.pInfo->lcflag = 1;
12+
13++ /* Handle the PKWare verification bit, bit 2 (0x0004) of internal
14++ attributes. If this is set, then a verification checksum is in the
15++ first 3 bytes of the external attributes. In this case all we can use
16++ for setting file attributes is the last external attributes byte. */
17++ if (G.crec.internal_file_attributes & 0x0004)
18++ G.crec.external_file_attributes &= (ulg)0xff;
19++
20+ /* do Amigas (AMIGA_) also have volume labels? */
21+ if (IS_VOLID(G.crec.external_file_attributes) &&
22+ (G.pInfo->hostnum == FS_FAT_ || G.pInfo->hostnum == FS_HPFS_ ||
1@@ -0,0 +1,17 @@
2+From: Jérémy Bobbio <lunar@debian.org>
3+Subject: Remove build date
4+Bug-Debian: https://bugs.debian.org/782851
5+ In order to make unzip build reproducibly, we remove the
6+ (already optional) build date from the binary.
7+
8+--- a/unix/unix.c
9++++ b/unix/unix.c
10+@@ -1705,7 +1705,7 @@
11+ #endif /* Sun */
12+ #endif /* SGI */
13+
14+-#ifdef __DATE__
15++#if 0
16+ " on ", __DATE__
17+ #else
18+ "", ""
R repo/unzip/patches/unzip-6.0-x-option.patch =>
repo/unzip/patches/20-unzip-uidgid-fix.patch
+12,
-11
1@@ -1,19 +1,20 @@
2---- ./process.c.orig 2009-03-06 02:25:10.000000000 +0100
3-+++ ./process.c
4-@@ -2901,9 +2901,9 @@
5- */
6-
7+From: sms
8+Subject: Restore uid and gid information when requested
9+Bug-Debian: http://bugs.debian.org/689212
10+X-Debian-version: 6.0-8
11+
12+--- a/process.c
13++++ b/process.c
14+@@ -2904,7 +2904,7 @@
15 #ifdef IZ_HAVE_UXUIDGID
16-- if (eb_len >= EB_UX3_MINLEN
17-- && z_uidgid != NULL
18+ if (eb_len >= EB_UX3_MINLEN
19+ && z_uidgid != NULL
20 - && (*((EB_HEADSIZE + 0) + ef_buf) == 1)
21-+ if ((eb_len >= EB_UX3_MINLEN)
22-+ && (z_uidgid != NULL)
23-+ && ((*((EB_HEADSIZE + 0) + ef_buf) == 1)))
24++ && (*((EB_HEADSIZE + 0) + ef_buf) == 1))
25 /* only know about version 1 */
26 {
27 uch uid_size;
28-@@ -2915,10 +2915,10 @@
29+@@ -2916,10 +2916,10 @@
30 flags &= ~0x0ff; /* ignore any previous UNIX field */
31
32 if ( read_ux3_value((EB_HEADSIZE + 2) + ef_buf,
1@@ -0,0 +1,15 @@
2+From: "Steven M. Schweda" <sms@antinode.info>
3+Subject: Fix lame code in fileio.c
4+Bug-Debian: https://bugs.debian.org/929502
5+X-Debian-version: 6.0-23
6+
7+--- a/fileio.c
8++++ b/fileio.c
9+@@ -2477,6 +2477,7 @@
10+ */
11+ return (((zusz_t)sig[7]) << 56)
12+ + (((zusz_t)sig[6]) << 48)
13++ + (((zusz_t)sig[5]) << 40)
14+ + (((zusz_t)sig[4]) << 32)
15+ + (zusz_t)((((ulg)sig[3]) << 24)
16+ + (((ulg)sig[2]) << 16)
R repo/unzip/patches/unzip-6.0-cve-2014-8139.patch =>
repo/unzip/patches/CVE-2014-8139.patch
+7,
-11
1@@ -1,15 +1,13 @@
2-diff --git a/extract.c b/extract.c
3-index 9ef80b3..c741b5f 100644
4 --- a/extract.c
5 +++ b/extract.c
6 @@ -1,5 +1,5 @@
7 /*
8 - Copyright (c) 1990-2009 Info-ZIP. All rights reserved.
9 + Copyright (c) 1990-2014 Info-ZIP. All rights reserved.
10-
11+
12 See the accompanying file LICENSE, version 2009-Jan-02 or later
13 (the contents of which are also included in unzip.h) for terms of use.
14-@@ -298,6 +298,8 @@ char ZCONST Far TruncNTSD[] =
15+@@ -298,6 +298,8 @@
16 #ifndef SFX
17 static ZCONST char Far InconsistEFlength[] = "bad extra-field entry:\n \
18 EF block length (%u bytes) exceeds remaining EF data (%u bytes)\n";
19@@ -18,17 +16,17 @@ index 9ef80b3..c741b5f 100644
20 static ZCONST char Far InvalidComprDataEAs[] =
21 " invalid compressed data for EAs\n";
22 # if (defined(WIN32) && defined(NTSD_EAS))
23-@@ -2020,7 +2022,8 @@ static int TestExtraField(__G__ ef, ef_len)
24+@@ -2032,7 +2034,8 @@
25 ebID = makeword(ef);
26 ebLen = (unsigned)makeword(ef+EB_LEN);
27-
28+
29 - if (ebLen > (ef_len - EB_HEADSIZE)) {
30 + if (ebLen > (ef_len - EB_HEADSIZE))
31 + {
32 /* Discovered some extra field inconsistency! */
33 if (uO.qflag)
34 Info(slide, 1, ((char *)slide, "%-22s ",
35-@@ -2155,11 +2158,29 @@ static int TestExtraField(__G__ ef, ef_len)
36+@@ -2167,11 +2170,29 @@
37 }
38 break;
39 case EF_PKVMS:
40@@ -63,17 +61,15 @@ index 9ef80b3..c741b5f 100644
41 break;
42 case EF_PKW32:
43 case EF_PKUNIX:
44-diff --git a/unzpriv.h b/unzpriv.h
45-index 005cee0..5c83a6e 100644
46 --- a/unzpriv.h
47 +++ b/unzpriv.h
48 @@ -1806,6 +1806,8 @@
49 #define EB_NTSD_VERSION 4 /* offset of NTSD version byte */
50 #define EB_NTSD_MAX_VER (0) /* maximum version # we know how to handle */
51-
52+
53 +#define EB_PKVMS_MINLEN 4 /* minimum data length of PKVMS extra block */
54 +
55 #define EB_ASI_CRC32 0 /* offset of ASI Unix field's crc32 checksum */
56 #define EB_ASI_MODE 4 /* offset of ASI Unix permission mode field */
57-
58+
59
R repo/unzip/patches/unzip-6.0-cve-2014-8140.patch =>
repo/unzip/patches/CVE-2014-8140.patch
+8,
-7
1@@ -1,8 +1,9 @@
2-diff --git a/extract.c b/extract.c
3-index c741b5f..e4a4c7b 100644
4---- a/extract.c
5-+++ b/extract.c
6-@@ -2240,10 +2240,17 @@ static int test_compr_eb(__G__ eb, eb_size, compr_offset, test_uc_ebdata)
7+From RedHat: https://bugzilla.redhat.com/attachment.cgi?id=969621&action=diff
8+(unzip60/ path prefix added)
9+
10+--- unzip60/extract.c 2009-03-14 02:32:52.000000000 +0100
11++++ unzip60/extract.c 2014-12-05 22:43:13.000000000 +0100
12+@@ -2221,10 +2234,17 @@ static int test_compr_eb(__G__ eb, eb_si
13 if (compr_offset < 4) /* field is not compressed: */
14 return PK_OK; /* do nothing and signal OK */
15
16@@ -21,5 +22,5 @@ index c741b5f..e4a4c7b 100644
17 + ((eb_ucsize > 0L) && (eb_size <= (compr_offset + EB_CMPRHEADLEN))))
18 + return IZ_EF_TRUNC; /* no/bad compressed data! */
19
20- method = makeword(eb + (EB_HEADSIZE + compr_offset));
21- if ((method == STORED) && (eb_size != compr_offset + EB_CMPRHEADLEN + eb_ucsize))
22+ if (
23+ #ifdef INT_16BIT
R repo/unzip/patches/unzip-6.0-cve-2014-8141.patch =>
repo/unzip/patches/CVE-2014-8141.patch
+33,
-35
1@@ -1,43 +1,16 @@
2-diff --git a/fileio.c b/fileio.c
3-index 03fc4be..2a61a30 100644
4---- a/fileio.c
5-+++ b/fileio.c
6-@@ -176,6 +176,8 @@ static ZCONST char Far FilenameTooLongTrunc[] =
7- #endif
8- static ZCONST char Far ExtraFieldTooLong[] =
9- "warning: extra field too long (%d). Ignoring...\n";
10-+static ZCONST char Far ExtraFieldCorrupt[] =
11-+ "warning: extra field (type: 0x%04x) corrupt. Continuing...\n";
12-
13- #ifdef WINDLL
14- static ZCONST char Far DiskFullQuery[] =
15-@@ -2300,7 +2302,13 @@ int do_string(__G__ length, option) /* return PK-type error code */
16- length = length2;
17- }
18- /* Looks like here is where extra fields are read */
19-- getZip64Data(__G__ G.extra_field, length);
20-+ if (getZip64Data(__G__ G.extra_field, length) != PK_COOL)
21-+ {
22-+ Info(slide, 0x401, ((char *)slide,
23-+ LoadFarString( ExtraFieldCorrupt), EF_PKSZ64));
24-+ error = PK_WARN;
25-+ }
26-+
27- #ifdef UNICODE_SUPPORT
28- G.unipath_filename = NULL;
29- if (G.UzO.U_flag < 2) {
30-diff --git a/process.c b/process.c
31-index be6e006..0d57ab4 100644
32---- a/process.c
33-+++ b/process.c
34-@@ -1,5 +1,5 @@
35+From RedHat: https://bugzilla.redhat.com/attachment.cgi?id=969625&action=diff
36+(unzip60/ path prefix added)
37+
38+--- unzip60/process.c 2009-03-06 02:25:10.000000000 +0100
39++++ unzip60/process.c 2014-12-05 22:42:39.000000000 +0100
40+@@ -1,5 +1,5 @@
41 /*
42 - Copyright (c) 1990-2009 Info-ZIP. All rights reserved.
43 + Copyright (c) 1990-2014 Info-ZIP. All rights reserved.
44
45 See the accompanying file LICENSE, version 2009-Jan-02 or later
46 (the contents of which are also included in unzip.h) for terms of use.
47-@@ -1894,48 +1894,83 @@ int getZip64Data(__G__ ef_buf, ef_len)
48+@@ -1888,48 +1888,82 @@ int getZip64Data(__G__ ef_buf, ef_len)
49 and a 4-byte version of disk start number.
50 Sets both local header and central header fields. Not terribly clever,
51 but it means that this procedure is only called in one place.
52@@ -76,7 +49,7 @@ index be6e006..0d57ab4 100644
53 break;
54 }
55 - if (eb_id == EF_PKSZ64) {
56-
57+-
58 + if (eb_id == EF_PKSZ64)
59 + {
60 int offset = EB_HEADSIZE;
61@@ -136,3 +109,28 @@ index be6e006..0d57ab4 100644
62 ef_buf += (eb_len + EB_HEADSIZE);
63 ef_len -= (eb_len + EB_HEADSIZE);
64 }
65+--- unzip60/fileio.c 2009-04-20 02:03:44.000000000 +0200
66++++ unzip60/fileio.c 2014-12-05 22:44:16.000000000 +0100
67+@@ -176,6 +176,8 @@ static ZCONST char Far FilenameTooLongTr
68+ #endif
69+ static ZCONST char Far ExtraFieldTooLong[] =
70+ "warning: extra field too long (%d). Ignoring...\n";
71++static ZCONST char Far ExtraFieldCorrupt[] =
72++ "warning: extra field (type: 0x%04x) corrupt. Continuing...\n";
73+
74+ #ifdef WINDLL
75+ static ZCONST char Far DiskFullQuery[] =
76+@@ -2295,7 +2297,12 @@ int do_string(__G__ length, option) /*
77+ if (readbuf(__G__ (char *)G.extra_field, length) == 0)
78+ return PK_EOF;
79+ /* Looks like here is where extra fields are read */
80+- getZip64Data(__G__ G.extra_field, length);
81++ if (getZip64Data(__G__ G.extra_field, length) != PK_COOL)
82++ {
83++ Info(slide, 0x401, ((char *)slide,
84++ LoadFarString( ExtraFieldCorrupt), EF_PKSZ64));
85++ error = PK_WARN;
86++ }
87+ #ifdef UNICODE_SUPPORT
88+ G.unipath_filename = NULL;
89+ if (G.UzO.U_flag < 2) {
+42,
-0
1@@ -0,0 +1,42 @@
2+From 190040ebfcf5395a6ccedede2cc9343d34f0a108 Mon Sep 17 00:00:00 2001
3+From: mancha <mancha1 AT zoho DOT com>
4+Date: Wed, 11 Feb 2015
5+Subject: Info-ZIP UnZip buffer overflow
6+
7+By carefully crafting a corrupt ZIP archive with "extra fields" that
8+purport to have compressed blocks larger than the corresponding
9+uncompressed blocks in STORED no-compression mode, an attacker can
10+trigger a heap overflow that can result in application crash or
11+possibly have other unspecified impact.
12+
13+This patch ensures that when extra fields use STORED mode, the
14+"compressed" and uncompressed block sizes match.
15+
16+---
17+ extract.c | 8 ++++++++
18+ 1 file changed, 8 insertions(+)
19+
20+--- a/extract.c
21++++ b/extract.c
22+@@ -2217,6 +2217,7 @@ static int test_compr_eb(__G__ eb, eb_si
23+ ulg eb_ucsize;
24+ uch *eb_ucptr;
25+ int r;
26++ ush method;
27+
28+ if (compr_offset < 4) /* field is not compressed: */
29+ return PK_OK; /* do nothing and signal OK */
30+@@ -2226,6 +2227,13 @@ static int test_compr_eb(__G__ eb, eb_si
31+ eb_size <= (compr_offset + EB_CMPRHEADLEN)))
32+ return IZ_EF_TRUNC; /* no compressed data! */
33+
34++ method = makeword(eb + (EB_HEADSIZE + compr_offset));
35++ if ((method == STORED) &&
36++ (eb_size - compr_offset - EB_CMPRHEADLEN != eb_ucsize))
37++ return PK_ERR; /* compressed & uncompressed
38++ * should match in STORED
39++ * method */
40++
41+ if (
42+ #ifdef INT_16BIT
43+ (((ulg)(extent)eb_ucsize) != eb_ucsize) ||
R repo/unzip/patches/unzip-6.0-overflow-long-fsize.patch =>
repo/unzip/patches/CVE-2014-9913.patch
+9,
-14
1@@ -1,24 +1,19 @@
2-diff --git a/list.c b/list.c
3-index f7359c3..4c3d703 100644
4+From: "Steven M. Schweda" <sms@antinode.info>
5+Subject: Fix CVE-2014-9913, buffer overflow in unzip
6+Bug: https://sourceforge.net/p/infozip/bugs/27/
7+Bug-Debian: https://bugs.debian.org/847485
8+Bug-Ubuntu: https://launchpad.net/bugs/387350
9+X-Debian-version: 6.0-21
10+
11 --- a/list.c
12 +++ b/list.c
13-@@ -97,7 +97,7 @@ int list_files(__G) /* return PK-type error code */
14- {
15- int do_this_file=FALSE, cfactor, error, error_in_archive=PK_COOL;
16- #ifndef WINDLL
17-- char sgn, cfactorstr[10];
18-+ char sgn, cfactorstr[13];
19- int longhdr=(uO.vflag>1);
20- #endif
21- int date_format;
22-@@ -339,7 +339,19 @@ int list_files(__G) /* return PK-type error code */
23+@@ -339,7 +339,18 @@
24 G.crec.compression_method == ENHDEFLATED) {
25 methbuf[5] = dtype[(G.crec.general_purpose_bit_flag>>1) & 3];
26 } else if (methnum >= NUM_METHODS) {
27 - sprintf(&methbuf[4], "%03u", G.crec.compression_method);
28 + /* 2013-02-26 SMS.
29-+ * http://sourceforge.net/tracker/?func=detail
30-+ * &aid=2861648&group_id=118012&atid=679786
31++ * http://sourceforge.net/p/infozip/bugs/27/ CVE-2014-9913.
32 + * Unexpectedly large compression methods overflow
33 + * &methbuf[]. Use the old, three-digit decimal format
34 + * for values which fit. Otherwise, sacrifice the
R repo/unzip/patches/0001-Fix-CVE-2016-9844-rhbz-1404283.patch =>
repo/unzip/patches/CVE-2016-9844.patch
+8,
-19
1@@ -1,19 +1,12 @@
2-From 754137e70cf58a64ad524b704a86b651ba0cde07 Mon Sep 17 00:00:00 2001
3-From: Petr Stodulka <pstodulk@redhat.com>
4-Date: Wed, 14 Dec 2016 16:30:36 +0100
5-Subject: [PATCH] Fix CVE-2016-9844 (rhbz#1404283)
6+From: "Steven M. Schweda" <sms@antinode.info>
7+Subject: Fix CVE-2016-9844, buffer overflow in zipinfo
8+Bug-Debian: https://bugs.debian.org/847486
9+Bug-Ubuntu: https://launchpad.net/bugs/1643750
10+X-Debian-version: 6.0-21
11
12-Fixes buffer overflow in zipinfo in similar way like fix for
13-CVE-2014-9913 provided by upstream.
14----
15- zipinfo.c | 14 +++++++++++++-
16- 1 file changed, 13 insertions(+), 1 deletion(-)
17-
18-diff --git a/zipinfo.c b/zipinfo.c
19-index c03620e..accca2a 100644
20 --- a/zipinfo.c
21 +++ b/zipinfo.c
22-@@ -1984,7 +1984,19 @@ static int zi_short(__G) /* return PK-type error code */
23+@@ -1921,7 +1921,18 @@
24 ush dnum=(ush)((G.crec.general_purpose_bit_flag>>1) & 3);
25 methbuf[3] = dtype[dnum];
26 } else if (methnum >= NUM_METHODS) { /* unknown */
27@@ -26,14 +19,10 @@ index c03620e..accca2a 100644
28 + * and use four-digit hexadecimal.
29 + */
30 + if (G.crec.compression_method <= 999) {
31-+ sprintf( &methbuf[ 1], "%03u", G.crec.compression_method);
32++ sprintf( &methbuf[ 1], "%03u", G.crec.compression_method);
33 + } else {
34-+ sprintf( &methbuf[ 0], "%04X", G.crec.compression_method);
35++ sprintf( &methbuf[ 0], "%04X", G.crec.compression_method);
36 + }
37-+
38 }
39
40 for (k = 0; k < 15; ++k)
41---
42-2.5.5
43-
R repo/unzip/patches/unzip-6.0-cve-2018-1000035-heap-based-overflow.patch =>
repo/unzip/patches/CVE-2018-1000035.patch
+0,
-0
+13,
-0
1@@ -0,0 +1,13 @@
2+diff --git a/list.c b/list.c
3+index f7359c3..4c3d703 100644
4+--- a/list.c
5++++ b/list.c
6+@@ -97,7 +97,7 @@ int list_files(__G) /* return PK-type error code */
7+ {
8+ int do_this_file=FALSE, cfactor, error, error_in_archive=PK_COOL;
9+ #ifndef WINDLL
10+- char sgn, cfactorstr[10];
11++ char sgn, cfactorstr[13];
12+ int longhdr=(uO.vflag>1);
13+ #endif
14+ int date_format;
+54,
-0
1@@ -0,0 +1,54 @@
2+From 731d698377dbd1f5b1b90efeb8094602ed59fc40 Mon Sep 17 00:00:00 2001
3+From: Nils Bars <nils.bars@t-online.de>
4+Date: Mon, 17 Jan 2022 16:53:16 +0000
5+Subject: [PATCH] Fix null pointer dereference and use of uninitialized data
6+
7+This fixes a bug that causes use of uninitialized heap data if `readbuf` fails
8+to read as many bytes as indicated by the extra field length attribute.
9+Furthermore, this fixes a null pointer dereference if an archive contains an
10+`EF_UNIPATH` extra field but does not have a filename set.
11+---
12+ fileio.c | 5 ++++-
13+ process.c | 6 +++++-
14+ 2 files changed, 9 insertions(+), 2 deletions(-)
15+
16+diff --git a/fileio.c b/fileio.c
17+index 6290824..95ea68b 100644
18+--- a/fileio.c
19++++ b/fileio.c
20+@@ -2308,8 +2308,11 @@ int do_string(__G__ length, option) /* return PK-type error code */
21+ seek_zipf(__G__ G.cur_zipfile_bufstart - G.extra_bytes +
22+ (G.inptr-G.inbuf) + length);
23+ } else {
24+- if (readbuf(__G__ (char *)G.extra_field, length) == 0)
25++ unsigned bytes_read = readbuf(__G__ (char *)G.extra_field, length);
26++ if (bytes_read == 0)
27+ return PK_EOF;
28++ if (bytes_read != length)
29++ return PK_ERR;
30+ /* Looks like here is where extra fields are read */
31+ if (getZip64Data(__G__ G.extra_field, length) != PK_COOL)
32+ {
33+diff --git a/process.c b/process.c
34+index d2a846e..cba2463 100644
35+--- a/process.c
36++++ b/process.c
37+@@ -2064,10 +2064,14 @@ int getUnicodeData(__G__ ef_buf, ef_len)
38+ G.unipath_checksum = makelong(offset + ef_buf);
39+ offset += 4;
40+
41++ if (!G.filename_full) {
42++ /* Check if we have a unicode extra section but no filename set */
43++ return PK_ERR;
44++ }
45++
46+ /*
47+ * Compute 32-bit crc
48+ */
49+-
50+ chksum = crc32(chksum, (uch *)(G.filename_full),
51+ strlen(G.filename_full));
52+
53+--
54+2.25.1
55+
1@@ -0,0 +1,173 @@
2+From: Steven M. Schweda <sms@antinode.info>
3+Subject: Fix for CVE-2022-0529 and CVE-2022-0530
4+Bug-Debian: https://bugs.debian.org/1010355
5+X-Debian-version: 6.0-27
6+
7+--- a/fileio.c
8++++ b/fileio.c
9+@@ -171,8 +171,10 @@
10+ static ZCONST char Far FilenameTooLongTrunc[] =
11+ "warning: filename too long--truncating.\n";
12+ #ifdef UNICODE_SUPPORT
13++ static ZCONST char Far UFilenameCorrupt[] =
14++ "error: Unicode filename corrupt.\n";
15+ static ZCONST char Far UFilenameTooLongTrunc[] =
16+- "warning: Converted unicode filename too long--truncating.\n";
17++ "warning: Converted Unicode filename too long--truncating.\n";
18+ #endif
19+ static ZCONST char Far ExtraFieldTooLong[] =
20+ "warning: extra field too long (%d). Ignoring...\n";
21+@@ -2361,16 +2363,30 @@
22+ /* convert UTF-8 to local character set */
23+ fn = utf8_to_local_string(G.unipath_filename,
24+ G.unicode_escape_all);
25+- /* make sure filename is short enough */
26+- if (strlen(fn) >= FILNAMSIZ) {
27+- fn[FILNAMSIZ - 1] = '\0';
28++
29++ /* 2022-07-22 SMS, et al. CVE-2022-0530
30++ * Detect conversion failure, emit message.
31++ * Continue with unconverted name.
32++ */
33++ if (fn == NULL)
34++ {
35+ Info(slide, 0x401, ((char *)slide,
36+- LoadFarString(UFilenameTooLongTrunc)));
37+- error = PK_WARN;
38++ LoadFarString(UFilenameCorrupt)));
39++ error = PK_ERR;
40++ }
41++ else
42++ {
43++ /* make sure filename is short enough */
44++ if (strlen(fn) >= FILNAMSIZ) {
45++ fn[FILNAMSIZ - 1] = '\0';
46++ Info(slide, 0x401, ((char *)slide,
47++ LoadFarString(UFilenameTooLongTrunc)));
48++ error = PK_WARN;
49++ }
50++ /* replace filename with converted UTF-8 */
51++ strcpy(G.filename, fn);
52++ free(fn);
53+ }
54+- /* replace filename with converted UTF-8 */
55+- strcpy(G.filename, fn);
56+- free(fn);
57+ }
58+ # endif /* UNICODE_WCHAR */
59+ if (G.unipath_filename != G.filename_full)
60+--- a/process.c
61++++ b/process.c
62+@@ -222,6 +222,8 @@
63+ "\nwarning: Unicode Path version > 1\n";
64+ static ZCONST char Far UnicodeMismatchError[] =
65+ "\nwarning: Unicode Path checksum invalid\n";
66++ static ZCONST char Far UFilenameTooLongTrunc[] =
67++ "warning: filename too long (P1) -- truncating.\n";
68+ #endif
69+
70+
71+@@ -1915,7 +1917,7 @@
72+ Sets both local header and central header fields. Not terribly clever,
73+ but it means that this procedure is only called in one place.
74+
75+- 2014-12-05 SMS.
76++ 2014-12-05 SMS. (oCERT.org report.) CVE-2014-8141.
77+ Added checks to ensure that enough data are available before calling
78+ makeint64() or makelong(). Replaced various sizeof() values with
79+ simple ("4" or "8") constants. (The Zip64 structures do not depend
80+@@ -1947,9 +1949,10 @@
81+ ef_len - EB_HEADSIZE));
82+ break;
83+ }
84++
85+ if (eb_id == EF_PKSZ64)
86+ {
87+- int offset = EB_HEADSIZE;
88++ unsigned offset = EB_HEADSIZE;
89+
90+ if ((G.crec.ucsize == Z64FLGL) || (G.lrec.ucsize == Z64FLGL))
91+ {
92+@@ -2046,7 +2049,7 @@
93+ }
94+ if (eb_id == EF_UNIPATH) {
95+
96+- int offset = EB_HEADSIZE;
97++ unsigned offset = EB_HEADSIZE;
98+ ush ULen = eb_len - 5;
99+ ulg chksum = CRCVAL_INITIAL;
100+
101+@@ -2504,16 +2507,17 @@
102+ int state_dependent;
103+ int wsize = 0;
104+ int max_bytes = MB_CUR_MAX;
105+- char buf[9];
106++ char buf[ MB_CUR_MAX+ 1]; /* ("+1" not really needed?) */
107+ char *buffer = NULL;
108+ char *local_string = NULL;
109++ size_t buffer_size; /* CVE-2022-0529 */
110+
111+ for (wsize = 0; wide_string[wsize]; wsize++) ;
112+
113+ if (max_bytes < MAX_ESCAPE_BYTES)
114+ max_bytes = MAX_ESCAPE_BYTES;
115+-
116+- if ((buffer = (char *)malloc(wsize * max_bytes + 1)) == NULL) {
117++ buffer_size = wsize * max_bytes + 1; /* Reused below. */
118++ if ((buffer = (char *)malloc( buffer_size)) == NULL) {
119+ return NULL;
120+ }
121+
122+@@ -2551,8 +2555,28 @@
123+ } else {
124+ /* no MB for this wide */
125+ /* use escape for wide character */
126+- char *escape_string = wide_to_escape_string(wide_string[i]);
127+- strcat(buffer, escape_string);
128++ size_t buffer_len;
129++ size_t escape_string_len;
130++ char *escape_string;
131++ int err_msg = 0;
132++
133++ escape_string = wide_to_escape_string(wide_string[i]);
134++ buffer_len = strlen( buffer);
135++ escape_string_len = strlen( escape_string);
136++
137++ /* Append escape string, as space allows. */
138++ /* 2022-07-18 SMS, et al. CVE-2022-0529 */
139++ if (escape_string_len > buffer_size- buffer_len- 1)
140++ {
141++ escape_string_len = buffer_size- buffer_len- 1;
142++ if (err_msg == 0)
143++ {
144++ err_msg = 1;
145++ Info(slide, 0x401, ((char *)slide,
146++ LoadFarString( UFilenameTooLongTrunc)));
147++ }
148++ }
149++ strncat( buffer, escape_string, escape_string_len);
150+ free(escape_string);
151+ }
152+ }
153+@@ -2604,9 +2628,18 @@
154+ ZCONST char *utf8_string;
155+ int escape_all;
156+ {
157+- zwchar *wide = utf8_to_wide_string(utf8_string);
158+- char *loc = wide_to_local_string(wide, escape_all);
159+- free(wide);
160++ zwchar *wide;
161++ char *loc = NULL;
162++
163++ wide = utf8_to_wide_string( utf8_string);
164++
165++ /* 2022-07-25 SMS, et al. CVE-2022-0530 */
166++ if (wide != NULL)
167++ {
168++ loc = wide_to_local_string( wide, escape_all);
169++ free( wide);
170++ }
171++
172+ return loc;
173+ }
174+
+38,
-0
1@@ -0,0 +1,38 @@
2+From mboxrd@z Thu Jan 1 00:00:00 1970
3+From: Andreas Schwab <schwab@linux-m68k.org>
4+Subject: Re: "git archive" seems to be broken wrt zip files
5+Date: Sun, 11 Sep 2011 15:14:36 +0200
6+Jeff King <peff@peff.net> writes:
7+
8+> IOW, the zip file looks right. I wonder if this is actually a bug in
9+> "unzip".
10+
11+It is. This only happens if you have more then 16k entries and when one
12+of the 16k entry infos is reused it happend to be previously used for a
13+symlink entry.
14+
15+Here's a patch for unzip60 for reference:
16+
17+--- a/process.c
18++++ b/process.c
19+@@ -1751,6 +1751,12 @@ int process_cdir_file_hdr(__G) /* ret
20+ = (G.crec.general_purpose_bit_flag & (1 << 11)) == (1 << 11);
21+ #endif
22+
23++#ifdef SYMLINKS
24++ /* Initialize the symlink flag, may be set by the platform-specific
25++ mapattr function. */
26++ G.pInfo->symlink = 0;
27++#endif
28++
29+ return PK_COOL;
30+
31+ } /* end function process_cdir_file_hdr() */
32+
33+Andreas.
34+
35+--
36+Andreas Schwab, schwab@linux-m68k.org
37+GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
38+"And now for something completely different."
39+
+0,
-30
1@@ -1,30 +0,0 @@
2-unzip-6.0-bzip2-configure.patch
3-unzip-6.0-exec-shield.patch
4-unzip-6.0-close.patch
5-unzip-6.0-attribs-overflow.patch
6-unzip-6.0-configure.patch
7-unzip-6.0-manpage-fix.patch
8-unzip-6.0-fix-recmatch.patch
9-unzip-6.0-symlink.patch
10-unzip-6.0-caseinsensitive.patch
11-unzip-6.0-format-secure.patch
12-unzip-6.0-valgrind.patch
13-unzip-6.0-x-option.patch
14-unzip-6.0-overflow.patch
15-unzip-6.0-cve-2014-8139.patch
16-unzip-6.0-cve-2014-8140.patch
17-unzip-6.0-cve-2014-8141.patch
18-unzip-6.0-overflow-long-fsize.patch
19-unzip-6.0-heap-overflow-infloop.patch
20-unzip-6.0-alt-iconv-utf8.patch
21-unzip-6.0-alt-iconv-utf8-print.patch
22-0001-Fix-CVE-2016-9844-rhbz-1404283.patch
23-unzip-6.0-timestamp.patch
24-unzip-6.0-cve-2018-1000035-heap-based-overflow.patch
25-unzip-6.0-cve-2018-18384.patch
26-unzip-6.0-COVSCAN-fix-unterminated-string.patch
27-unzip-zipbomb-part1.patch
28-unzip-zipbomb-part2.patch
29-unzip-zipbomb-part3.patch
30-unzip-zipbomb-manpage.patch
31-unzip-6.0_CVE-2021-4217.patch
1@@ -1,131 +0,0 @@
2-From 06d1b08aef94984256cad3c5a54cedb10295681f Mon Sep 17 00:00:00 2001
3-From: Jakub Martisko <jamartis@redhat.com>
4-Date: Thu, 8 Nov 2018 09:31:18 +0100
5-Subject: [PATCH] Possible unterminated string fix
6-
7----
8- unix/unix.c | 4 +++-
9- unix/unxcfg.h | 2 +-
10- unzip.c | 12 ++++++++----
11- zipinfo.c | 12 ++++++++----
12- 4 files changed, 20 insertions(+), 10 deletions(-)
13-
14-diff --git a/unix/unix.c b/unix/unix.c
15-index 59b622d..cd57f80 100644
16---- a/unix/unix.c
17-+++ b/unix/unix.c
18-@@ -1945,7 +1945,9 @@ void init_conversion_charsets()
19- for(i = 0; i < sizeof(dos_charset_map)/sizeof(CHARSET_MAP); i++)
20- if(!strcasecmp(local_charset, dos_charset_map[i].local_charset)) {
21- strncpy(OEM_CP, dos_charset_map[i].archive_charset,
22-- sizeof(OEM_CP));
23-+ MAX_CP_NAME - 1);
24-+
25-+ OEM_CP[MAX_CP_NAME - 1] = '\0';
26- break;
27- }
28- }
29-diff --git a/unix/unxcfg.h b/unix/unxcfg.h
30-index 8729de2..9ee8cfe 100644
31---- a/unix/unxcfg.h
32-+++ b/unix/unxcfg.h
33-@@ -228,7 +228,7 @@ typedef struct stat z_stat;
34- /* and notfirstcall are used by do_wild(). */
35-
36-
37--#define MAX_CP_NAME 25
38-+#define MAX_CP_NAME 25 + 1
39-
40- #ifdef SETLOCALE
41- # undef SETLOCALE
42-diff --git a/unzip.c b/unzip.c
43-index 2d94a38..a485f2b 100644
44---- a/unzip.c
45-+++ b/unzip.c
46-@@ -1561,7 +1561,8 @@ int uz_opts(__G__ pargc, pargv)
47- "error: a valid character encoding should follow the -I argument"));
48- return(PK_PARAM);
49- }
50-- strncpy(ISO_CP, s, sizeof(ISO_CP));
51-+ strncpy(ISO_CP, s, MAX_CP_NAME - 1);
52-+ ISO_CP[MAX_CP_NAME - 1] = '\0';
53- } else { /* -I charset */
54- ++argv;
55- if(!(--argc > 0 && *argv != NULL && **argv != '-')) {
56-@@ -1570,7 +1571,8 @@ int uz_opts(__G__ pargc, pargv)
57- return(PK_PARAM);
58- }
59- s = *argv;
60-- strncpy(ISO_CP, s, sizeof(ISO_CP));
61-+ strncpy(ISO_CP, s, MAX_CP_NAME - 1);
62-+ ISO_CP[MAX_CP_NAME - 1] = '\0';
63- }
64- while(*(++s)); /* No params straight after charset name */
65- }
66-@@ -1665,7 +1667,8 @@ int uz_opts(__G__ pargc, pargv)
67- "error: a valid character encoding should follow the -I argument"));
68- return(PK_PARAM);
69- }
70-- strncpy(OEM_CP, s, sizeof(OEM_CP));
71-+ strncpy(OEM_CP, s, MAX_CP_NAME - 1);
72-+ OEM_CP[MAX_CP_NAME - 1] = '\0';
73- } else { /* -O charset */
74- ++argv;
75- if(!(--argc > 0 && *argv != NULL && **argv != '-')) {
76-@@ -1674,7 +1677,8 @@ int uz_opts(__G__ pargc, pargv)
77- return(PK_PARAM);
78- }
79- s = *argv;
80-- strncpy(OEM_CP, s, sizeof(OEM_CP));
81-+ strncpy(OEM_CP, s, MAX_CP_NAME - 1);
82-+ OEM_CP[MAX_CP_NAME - 1] = '\0';
83- }
84- while(*(++s)); /* No params straight after charset name */
85- }
86-diff --git a/zipinfo.c b/zipinfo.c
87-index accca2a..cb7e08d 100644
88---- a/zipinfo.c
89-+++ b/zipinfo.c
90-@@ -519,7 +519,8 @@ int zi_opts(__G__ pargc, pargv)
91- "error: a valid character encoding should follow the -I argument"));
92- return(PK_PARAM);
93- }
94-- strncpy(ISO_CP, s, sizeof(ISO_CP));
95-+ strncpy(ISO_CP, s, MAX_CP_NAME - 1);
96-+ ISO_CP[MAX_CP_NAME - 1] = '\0';
97- } else { /* -I charset */
98- ++argv;
99- if(!(--argc > 0 && *argv != NULL && **argv != '-')) {
100-@@ -528,7 +529,8 @@ int zi_opts(__G__ pargc, pargv)
101- return(PK_PARAM);
102- }
103- s = *argv;
104-- strncpy(ISO_CP, s, sizeof(ISO_CP));
105-+ strncpy(ISO_CP, s, MAX_CP_NAME - 1);
106-+ ISO_CP[MAX_CP_NAME - 1] = '\0';
107- }
108- while(*(++s)); /* No params straight after charset name */
109- }
110-@@ -568,7 +570,8 @@ int zi_opts(__G__ pargc, pargv)
111- "error: a valid character encoding should follow the -I argument"));
112- return(PK_PARAM);
113- }
114-- strncpy(OEM_CP, s, sizeof(OEM_CP));
115-+ strncpy(OEM_CP, s, MAX_CP_NAME - 1);
116-+ OEM_CP[MAX_CP_NAME - 1] = '\0';
117- } else { /* -O charset */
118- ++argv;
119- if(!(--argc > 0 && *argv != NULL && **argv != '-')) {
120-@@ -577,7 +580,8 @@ int zi_opts(__G__ pargc, pargv)
121- return(PK_PARAM);
122- }
123- s = *argv;
124-- strncpy(OEM_CP, s, sizeof(OEM_CP));
125-+ strncpy(OEM_CP, s, MAX_CP_NAME - 1);
126-+ OEM_CP[MAX_CP_NAME - 1] = '\0';
127- }
128- while(*(++s)); /* No params straight after charset name */
129- }
130---
131-2.14.5
132-
1@@ -1,381 +0,0 @@
2-From ca0212ba19b64488b9e8459a762c11ecd6e7d0bd Mon Sep 17 00:00:00 2001
3-From: Petr Stodulka <pstodulk@redhat.com>
4-Date: Tue, 24 Nov 2015 17:56:11 +0100
5-Subject: [PATCH] print correctly non-ascii filenames
6-
7----
8- extract.c | 289 ++++++++++++++++++++++++++++++++++++++++++++++++--------------
9- unzpriv.h | 7 ++
10- 2 files changed, 233 insertions(+), 63 deletions(-)
11-
12-diff --git a/extract.c b/extract.c
13-index 0ee4e93..741b7e0 100644
14---- a/extract.c
15-+++ b/extract.c
16-@@ -2648,8 +2648,21 @@ static void set_deferred_symlink(__G__ slnk_entry)
17- } /* end function set_deferred_symlink() */
18- #endif /* SYMLINKS */
19-
20-+/*
21-+ * If Unicode is supported, assume we have what we need to do this
22-+ * check using wide characters, avoiding MBCS issues.
23-+ */
24-
25--
26-+#ifndef UZ_FNFILTER_REPLACECHAR
27-+ /* A convenient choice for the replacement of unprintable char codes is
28-+ * the "single char wildcard", as this character is quite unlikely to
29-+ * appear in filenames by itself. The following default definition
30-+ * sets the replacement char to a question mark as the most common
31-+ * "single char wildcard"; this setting should be overridden in the
32-+ * appropiate system-specific configuration header when needed.
33-+ */
34-+# define UZ_FNFILTER_REPLACECHAR '?'
35-+#endif
36-
37- /*************************/
38- /* Function fnfilter() */ /* here instead of in list.c for SFX */
39-@@ -2661,48 +2674,168 @@ char *fnfilter(raw, space, size) /* convert name to safely printable form */
40- extent size;
41- {
42- #ifndef NATIVE /* ASCII: filter ANSI escape codes, etc. */
43-- ZCONST uch *r=(ZCONST uch *)raw;
44-+ ZCONST uch *r; // =(ZCONST uch *)raw;
45- uch *s=space;
46- uch *slim=NULL;
47- uch *se=NULL;
48- int have_overflow = FALSE;
49-
50-- if (size > 0) {
51-- slim = space + size
52--#ifdef _MBCS
53-- - (MB_CUR_MAX - 1)
54--#endif
55-- - 4;
56-+# if defined( UNICODE_SUPPORT) && defined( _MBCS)
57-+/* If Unicode support is enabled, and we have multi-byte characters,
58-+ * then do the isprint() checks by first converting to wide characters
59-+ * and checking those. This avoids our having to parse multi-byte
60-+ * characters for ourselves. After the wide-char replacements have been
61-+ * made, the wide string is converted back to the local character set.
62-+ */
63-+ wchar_t *wstring; /* wchar_t version of raw */
64-+ size_t wslen; /* length of wstring */
65-+ wchar_t *wostring; /* wchar_t version of output string */
66-+ size_t woslen; /* length of wostring */
67-+ char *newraw; /* new raw */
68-+
69-+ /* 2012-11-06 SMS.
70-+ * Changed to check the value returned by mbstowcs(), and bypass the
71-+ * Unicode processing if it fails. This seems to fix a problem
72-+ * reported in the SourceForge forum, but it's not clear that we
73-+ * should be doing any Unicode processing without some evidence that
74-+ * the name actually is Unicode. (Check bit 11 in the flags before
75-+ * coming here?)
76-+ * http://sourceforge.net/p/infozip/bugs/40/
77-+ */
78-+
79-+ if (MB_CUR_MAX <= 1)
80-+ {
81-+ /* There's no point to converting multi-byte chars if there are
82-+ * no multi-byte chars.
83-+ */
84-+ wslen = (size_t)-1;
85- }
86-- while (*r) {
87-- if (size > 0 && s >= slim && se == NULL) {
88-- se = s;
89-+ else
90-+ {
91-+ /* Get Unicode wide character count (for storage allocation). */
92-+ wslen = mbstowcs( NULL, raw, 0);
93-+ }
94-+
95-+ if (wslen != (size_t)-1)
96-+ {
97-+ /* Apparently valid Unicode. Allocate wide-char storage. */
98-+ wstring = (wchar_t *)malloc((wslen + 1) * sizeof(wchar_t));
99-+ if (wstring == NULL) {
100-+ strcpy( (char *)space, raw);
101-+ return (char *)space;
102- }
103--#ifdef QDOS
104-- if (qlflag & 2) {
105-- if (*r == '/' || *r == '.') {
106-+ wostring = (wchar_t *)malloc(2 * (wslen + 1) * sizeof(wchar_t));
107-+ if (wostring == NULL) {
108-+ free(wstring);
109-+ strcpy( (char *)space, raw);
110-+ return (char *)space;
111-+ }
112-+
113-+ /* Convert the multi-byte Unicode to wide chars. */
114-+ wslen = mbstowcs(wstring, raw, wslen + 1);
115-+
116-+ /* Filter the wide-character string. */
117-+ fnfilterw( wstring, wostring, (2 * (wslen + 1) * sizeof(wchar_t)));
118-+
119-+ /* Convert filtered wide chars back to multi-byte. */
120-+ woslen = wcstombs( NULL, wostring, 0);
121-+ if ((newraw = malloc(woslen + 1)) == NULL) {
122-+ free(wstring);
123-+ free(wostring);
124-+ strcpy( (char *)space, raw);
125-+ return (char *)space;
126-+ }
127-+ woslen = wcstombs( newraw, wostring, (woslen * MB_CUR_MAX) + 1);
128-+
129-+ if (size > 0) {
130-+ slim = space + size - 4;
131-+ }
132-+ r = (ZCONST uch *)newraw;
133-+ while (*r) {
134-+ if (size > 0 && s >= slim && se == NULL) {
135-+ se = s;
136-+ }
137-+# ifdef QDOS
138-+ if (qlflag & 2) {
139-+ if (*r == '/' || *r == '.') {
140-+ if (se != NULL && (s > (space + (size-3)))) {
141-+ have_overflow = TRUE;
142-+ break;
143-+ }
144-+ ++r;
145-+ *s++ = '_';
146-+ continue;
147-+ }
148-+ } else
149-+# endif
150-+ {
151- if (se != NULL && (s > (space + (size-3)))) {
152- have_overflow = TRUE;
153- break;
154- }
155-- ++r;
156-- *s++ = '_';
157-- continue;
158-+ *s++ = *r++;
159- }
160-- } else
161-+ }
162-+ if (have_overflow) {
163-+ strcpy((char *)se, "...");
164-+ } else {
165-+ *s = '\0';
166-+ }
167-+
168-+ free(wstring);
169-+ free(wostring);
170-+ free(newraw);
171-+ }
172-+ else
173-+# endif /* defined( UNICODE_SUPPORT) && defined( _MBCS) */
174-+ {
175-+ /* No Unicode support, or apparently invalid Unicode. */
176-+ r = (ZCONST uch *)raw;
177-+
178-+ if (size > 0) {
179-+ slim = space + size
180-+#ifdef _MBCS
181-+ - (MB_CUR_MAX - 1)
182-+#endif
183-+ - 4;
184-+ }
185-+ while (*r) {
186-+ if (size > 0 && s >= slim && se == NULL) {
187-+ se = s;
188-+ }
189-+#ifdef QDOS
190-+ if (qlflag & 2) {
191-+ if (*r == '/' || *r == '.') {
192-+ if (se != NULL && (s > (space + (size-3)))) {
193-+ have_overflow = TRUE;
194-+ break;
195-+ }
196-+ ++r;
197-+ *s++ = '_';
198-+ continue;
199-+ }
200-+ } else
201- #endif
202- #ifdef HAVE_WORKING_ISPRINT
203--# ifndef UZ_FNFILTER_REPLACECHAR
204-- /* A convenient choice for the replacement of unprintable char codes is
205-- * the "single char wildcard", as this character is quite unlikely to
206-- * appear in filenames by itself. The following default definition
207-- * sets the replacement char to a question mark as the most common
208-- * "single char wildcard"; this setting should be overridden in the
209-- * appropiate system-specific configuration header when needed.
210-- */
211--# define UZ_FNFILTER_REPLACECHAR '?'
212--# endif
213-- if (!isprint(*r)) {
214-+ if (!isprint(*r)) {
215-+ if (*r < 32) {
216-+ /* ASCII control codes are escaped as "^{letter}". */
217-+ if (se != NULL && (s > (space + (size-4)))) {
218-+ have_overflow = TRUE;
219-+ break;
220-+ }
221-+ *s++ = '^', *s++ = (uch)(64 + *r++);
222-+ } else {
223-+ /* Other unprintable codes are replaced by the
224-+ * placeholder character. */
225-+ if (se != NULL && (s > (space + (size-3)))) {
226-+ have_overflow = TRUE;
227-+ break;
228-+ }
229-+ *s++ = UZ_FNFILTER_REPLACECHAR;
230-+ INCSTR(r);
231-+ }
232-+#else /* !HAVE_WORKING_ISPRINT */
233- if (*r < 32) {
234- /* ASCII control codes are escaped as "^{letter}". */
235- if (se != NULL && (s > (space + (size-4)))) {
236-@@ -2710,47 +2843,30 @@ char *fnfilter(raw, space, size) /* convert name to safely printable form */
237- break;
238- }
239- *s++ = '^', *s++ = (uch)(64 + *r++);
240-+#endif /* ?HAVE_WORKING_ISPRINT */
241- } else {
242-- /* Other unprintable codes are replaced by the
243-- * placeholder character. */
244-+#ifdef _MBCS
245-+ unsigned i = CLEN(r);
246-+ if (se != NULL && (s > (space + (size-i-2)))) {
247-+ have_overflow = TRUE;
248-+ break;
249-+ }
250-+ for (; i > 0; i--)
251-+ *s++ = *r++;
252-+#else
253- if (se != NULL && (s > (space + (size-3)))) {
254- have_overflow = TRUE;
255- break;
256- }
257-- *s++ = UZ_FNFILTER_REPLACECHAR;
258-- INCSTR(r);
259-- }
260--#else /* !HAVE_WORKING_ISPRINT */
261-- if (*r < 32) {
262-- /* ASCII control codes are escaped as "^{letter}". */
263-- if (se != NULL && (s > (space + (size-4)))) {
264-- have_overflow = TRUE;
265-- break;
266-- }
267-- *s++ = '^', *s++ = (uch)(64 + *r++);
268--#endif /* ?HAVE_WORKING_ISPRINT */
269-- } else {
270--#ifdef _MBCS
271-- unsigned i = CLEN(r);
272-- if (se != NULL && (s > (space + (size-i-2)))) {
273-- have_overflow = TRUE;
274-- break;
275-- }
276-- for (; i > 0; i--)
277- *s++ = *r++;
278--#else
279-- if (se != NULL && (s > (space + (size-3)))) {
280-- have_overflow = TRUE;
281-- break;
282-- }
283-- *s++ = *r++;
284- #endif
285-- }
286-- }
287-- if (have_overflow) {
288-- strcpy((char *)se, "...");
289-- } else {
290-- *s = '\0';
291-+ }
292-+ }
293-+ if (have_overflow) {
294-+ strcpy((char *)se, "...");
295-+ } else {
296-+ *s = '\0';
297-+ }
298- }
299-
300- #ifdef WINDLL
301-@@ -2772,6 +2888,53 @@ char *fnfilter(raw, space, size) /* convert name to safely printable form */
302- } /* end function fnfilter() */
303-
304-
305-+#if defined( UNICODE_SUPPORT) && defined( _MBCS)
306-+
307-+/****************************/
308-+/* Function fnfilter[w]() */ /* (Here instead of in list.c for SFX.) */
309-+/****************************/
310-+
311-+/* fnfilterw() - Convert wide name to safely printable form. */
312-+
313-+/* fnfilterw() - Convert wide-character name to safely printable form. */
314-+
315-+wchar_t *fnfilterw( src, dst, siz)
316-+ ZCONST wchar_t *src; /* Pointer to source char (string). */
317-+ wchar_t *dst; /* Pointer to destination char (string). */
318-+ extent siz; /* Not used (!). */
319-+{
320-+ wchar_t *dsx = dst;
321-+
322-+ /* Filter the wide chars. */
323-+ while (*src)
324-+ {
325-+ if (iswprint( *src))
326-+ {
327-+ /* Printable code. Copy it. */
328-+ *dst++ = *src;
329-+ }
330-+ else
331-+ {
332-+ /* Unprintable code. Substitute something printable for it. */
333-+ if (*src < 32)
334-+ {
335-+ /* Replace ASCII control code with "^{letter}". */
336-+ *dst++ = (wchar_t)'^';
337-+ *dst++ = (wchar_t)(64 + *src);
338-+ }
339-+ else
340-+ {
341-+ /* Replace other unprintable code with the placeholder. */
342-+ *dst++ = (wchar_t)UZ_FNFILTER_REPLACECHAR;
343-+ }
344-+ }
345-+ src++;
346-+ }
347-+ *dst = (wchar_t)0; /* NUL-terminate the destination string. */
348-+ return dsx;
349-+} /* fnfilterw(). */
350-+
351-+#endif /* defined( UNICODE_SUPPORT) && defined( _MBCS) */
352-
353-
354- #ifdef SET_DIR_ATTRIB
355-diff --git a/unzpriv.h b/unzpriv.h
356-index 22d3923..e48a652 100644
357---- a/unzpriv.h
358-+++ b/unzpriv.h
359-@@ -1212,6 +1212,7 @@
360- # ifdef UNICODE_WCHAR
361- # if !(defined(_WIN32_WCE) || defined(POCKET_UNZIP))
362- # include <wchar.h>
363-+# include <wctype.h>
364- # endif
365- # endif
366- # ifndef _MBCS /* no need to include <locale.h> twice, see below */
367-@@ -2410,6 +2411,12 @@ int memflush OF((__GPRO__ ZCONST uch *rawbuf, ulg size));
368- char *fnfilter OF((ZCONST char *raw, uch *space,
369- extent size));
370-
371-+# if defined( UNICODE_SUPPORT) && defined( _MBCS)
372-+wchar_t *fnfilterw OF((ZCONST wchar_t *src, wchar_t *dst,
373-+ extent siz));
374-+#endif
375-+
376-+
377- /*---------------------------------------------------------------------------
378- Decompression functions:
379- ---------------------------------------------------------------------------*/
380---
381-2.4.3
382-
1@@ -1,398 +0,0 @@
2-From: Giovanni Scafora <giovanni.archlinux.org>
3-Subject: unzip files encoded with non-latin, non-unicode file names
4-Last-Update: 2015-02-11
5-
6-Updated 2015-02-11 by Marc Deslauriers <marc.deslauriers@canonical.com>
7-to fix buffer overflow in charset_to_intern()
8-
9-Index: unzip-6.0/unix/unix.c
10-===================================================================
11---- unzip-6.0.orig/unix/unix.c 2015-02-11 08:46:43.675324290 -0500
12-+++ unzip-6.0/unix/unix.c 2015-02-11 09:18:04.902081319 -0500
13-@@ -30,6 +30,9 @@
14- #define UNZIP_INTERNAL
15- #include "unzip.h"
16-
17-+#include <iconv.h>
18-+#include <langinfo.h>
19-+
20- #ifdef SCO_XENIX
21- # define SYSNDIR
22- #else /* SCO Unix, AIX, DNIX, TI SysV, Coherent 4.x, ... */
23-@@ -1874,3 +1877,102 @@
24- }
25- }
26- #endif /* QLZIP */
27-+
28-+
29-+typedef struct {
30-+ char *local_charset;
31-+ char *archive_charset;
32-+} CHARSET_MAP;
33-+
34-+/* A mapping of local <-> archive charsets used by default to convert filenames
35-+ * of DOS/Windows Zip archives. Currently very basic. */
36-+static CHARSET_MAP dos_charset_map[] = {
37-+ { "ANSI_X3.4-1968", "CP850" },
38-+ { "ISO-8859-1", "CP850" },
39-+ { "CP1252", "CP850" },
40-+ { "UTF-8", "CP866" },
41-+ { "KOI8-R", "CP866" },
42-+ { "KOI8-U", "CP866" },
43-+ { "ISO-8859-5", "CP866" }
44-+};
45-+
46-+char OEM_CP[MAX_CP_NAME] = "";
47-+char ISO_CP[MAX_CP_NAME] = "";
48-+
49-+/* Try to guess the default value of OEM_CP based on the current locale.
50-+ * ISO_CP is left alone for now. */
51-+void init_conversion_charsets()
52-+{
53-+ const char *local_charset;
54-+ int i;
55-+
56-+ /* Make a guess only if OEM_CP not already set. */
57-+ if(*OEM_CP == '\0') {
58-+ local_charset = nl_langinfo(CODESET);
59-+ for(i = 0; i < sizeof(dos_charset_map)/sizeof(CHARSET_MAP); i++)
60-+ if(!strcasecmp(local_charset, dos_charset_map[i].local_charset)) {
61-+ strncpy(OEM_CP, dos_charset_map[i].archive_charset,
62-+ sizeof(OEM_CP));
63-+ break;
64-+ }
65-+ }
66-+}
67-+
68-+/* Convert a string from one encoding to the current locale using iconv().
69-+ * Be as non-intrusive as possible. If error is encountered during covertion
70-+ * just leave the string intact. */
71-+static void charset_to_intern(char *string, char *from_charset)
72-+{
73-+ iconv_t cd;
74-+ char *s,*d, *buf;
75-+ size_t slen, dlen, buflen;
76-+ const char *local_charset;
77-+
78-+ if(*from_charset == '\0')
79-+ return;
80-+
81-+ buf = NULL;
82-+ local_charset = nl_langinfo(CODESET);
83-+
84-+ if((cd = iconv_open(local_charset, from_charset)) == (iconv_t)-1)
85-+ return;
86-+
87-+ slen = strlen(string);
88-+ s = string;
89-+
90-+ /* Make sure OUTBUFSIZ + 1 never ends up smaller than FILNAMSIZ
91-+ * as this function also gets called with G.outbuf in fileio.c
92-+ */
93-+ buflen = FILNAMSIZ;
94-+ if (OUTBUFSIZ + 1 < FILNAMSIZ)
95-+ {
96-+ buflen = OUTBUFSIZ + 1;
97-+ }
98-+
99-+ d = buf = malloc(buflen);
100-+ if(!d)
101-+ goto cleanup;
102-+
103-+ bzero(buf,buflen);
104-+ dlen = buflen - 1;
105-+
106-+ if(iconv(cd, &s, &slen, &d, &dlen) == (size_t)-1)
107-+ goto cleanup;
108-+ strncpy(string, buf, buflen);
109-+
110-+ cleanup:
111-+ free(buf);
112-+ iconv_close(cd);
113-+}
114-+
115-+/* Convert a string from OEM_CP to the current locale charset. */
116-+inline void oem_intern(char *string)
117-+{
118-+ charset_to_intern(string, OEM_CP);
119-+}
120-+
121-+/* Convert a string from ISO_CP to the current locale charset. */
122-+inline void iso_intern(char *string)
123-+{
124-+ charset_to_intern(string, ISO_CP);
125-+}
126-Index: unzip-6.0/unix/unxcfg.h
127-===================================================================
128---- unzip-6.0.orig/unix/unxcfg.h 2015-02-11 08:46:43.675324290 -0500
129-+++ unzip-6.0/unix/unxcfg.h 2015-02-11 08:46:43.671324260 -0500
130-@@ -228,4 +228,30 @@
131- /* wild_dir, dirname, wildname, matchname[], dirnamelen, have_dirname, */
132- /* and notfirstcall are used by do_wild(). */
133-
134-+
135-+#define MAX_CP_NAME 25
136-+
137-+#ifdef SETLOCALE
138-+# undef SETLOCALE
139-+#endif
140-+#define SETLOCALE(category, locale) setlocale(category, locale)
141-+#include <locale.h>
142-+
143-+#ifdef _ISO_INTERN
144-+# undef _ISO_INTERN
145-+#endif
146-+#define _ISO_INTERN(str1) iso_intern(str1)
147-+
148-+#ifdef _OEM_INTERN
149-+# undef _OEM_INTERN
150-+#endif
151-+#ifndef IZ_OEM2ISO_ARRAY
152-+# define IZ_OEM2ISO_ARRAY
153-+#endif
154-+#define _OEM_INTERN(str1) oem_intern(str1)
155-+
156-+void iso_intern(char *);
157-+void oem_intern(char *);
158-+void init_conversion_charsets(void);
159-+
160- #endif /* !__unxcfg_h */
161-Index: unzip-6.0/unzip.c
162-===================================================================
163---- unzip-6.0.orig/unzip.c 2015-02-11 08:46:43.675324290 -0500
164-+++ unzip-6.0/unzip.c 2015-02-11 08:46:43.675324290 -0500
165-@@ -327,11 +327,21 @@
166- -2 just filenames but allow -h/-t/-z -l long Unix \"ls -l\" format\n\
167- -v verbose, multi-page format\n";
168-
169-+#ifndef UNIX
170- static ZCONST char Far ZipInfoUsageLine3[] = "miscellaneous options:\n\
171- -h print header line -t print totals for listed files or for all\n\
172- -z print zipfile comment -T print file times in sortable decimal format\
173- \n -C be case-insensitive %s\
174- -x exclude filenames that follow from listing\n";
175-+#else /* UNIX */
176-+static ZCONST char Far ZipInfoUsageLine3[] = "miscellaneous options:\n\
177-+ -h print header line -t print totals for listed files or for all\n\
178-+ -z print zipfile comment %c-T%c print file times in sortable decimal format\
179-+\n %c-C%c be case-insensitive %s\
180-+ -x exclude filenames that follow from listing\n\
181-+ -O CHARSET specify a character encoding for DOS, Windows and OS/2 archives\n\
182-+ -I CHARSET specify a character encoding for UNIX and other archives\n";
183-+#endif /* !UNIX */
184- #ifdef MORE
185- static ZCONST char Far ZipInfoUsageLine4[] =
186- " -M page output through built-in \"more\"\n";
187-@@ -664,6 +674,17 @@
188- -U use escapes for all non-ASCII Unicode -UU ignore any Unicode fields\n\
189- -C match filenames case-insensitively -L make (some) names \
190- lowercase\n %-42s -V retain VMS version numbers\n%s";
191-+#elif (defined UNIX)
192-+static ZCONST char Far UnzipUsageLine4[] = "\
193-+modifiers:\n\
194-+ -n never overwrite existing files -q quiet mode (-qq => quieter)\n\
195-+ -o overwrite files WITHOUT prompting -a auto-convert any text files\n\
196-+ -j junk paths (do not make directories) -aa treat ALL files as text\n\
197-+ -U use escapes for all non-ASCII Unicode -UU ignore any Unicode fields\n\
198-+ -C match filenames case-insensitively -L make (some) names \
199-+lowercase\n %-42s -V retain VMS version numbers\n%s\
200-+ -O CHARSET specify a character encoding for DOS, Windows and OS/2 archives\n\
201-+ -I CHARSET specify a character encoding for UNIX and other archives\n\n";
202- #else /* !VMS */
203- static ZCONST char Far UnzipUsageLine4[] = "\
204- modifiers:\n\
205-@@ -802,6 +823,10 @@
206- #endif /* UNICODE_SUPPORT */
207-
208-
209-+#ifdef UNIX
210-+ init_conversion_charsets();
211-+#endif
212-+
213- #if (defined(__IBMC__) && defined(__DEBUG_ALLOC__))
214- extern void DebugMalloc(void);
215-
216-@@ -1335,6 +1360,11 @@
217- argc = *pargc;
218- argv = *pargv;
219-
220-+#ifdef UNIX
221-+ extern char OEM_CP[MAX_CP_NAME];
222-+ extern char ISO_CP[MAX_CP_NAME];
223-+#endif
224-+
225- while (++argv, (--argc > 0 && *argv != NULL && **argv == '-')) {
226- s = *argv + 1;
227- while ((c = *s++) != 0) { /* "!= 0": prevent Turbo C warning */
228-@@ -1516,6 +1546,35 @@
229- }
230- break;
231- #endif /* MACOS */
232-+#ifdef UNIX
233-+ case ('I'):
234-+ if (negative) {
235-+ Info(slide, 0x401, ((char *)slide,
236-+ "error: encodings can't be negated"));
237-+ return(PK_PARAM);
238-+ } else {
239-+ if(*s) { /* Handle the -Icharset case */
240-+ /* Assume that charsets can't start with a dash to spot arguments misuse */
241-+ if(*s == '-') {
242-+ Info(slide, 0x401, ((char *)slide,
243-+ "error: a valid character encoding should follow the -I argument"));
244-+ return(PK_PARAM);
245-+ }
246-+ strncpy(ISO_CP, s, sizeof(ISO_CP));
247-+ } else { /* -I charset */
248-+ ++argv;
249-+ if(!(--argc > 0 && *argv != NULL && **argv != '-')) {
250-+ Info(slide, 0x401, ((char *)slide,
251-+ "error: a valid character encoding should follow the -I argument"));
252-+ return(PK_PARAM);
253-+ }
254-+ s = *argv;
255-+ strncpy(ISO_CP, s, sizeof(ISO_CP));
256-+ }
257-+ while(*(++s)); /* No params straight after charset name */
258-+ }
259-+ break;
260-+#endif /* ?UNIX */
261- case ('j'): /* junk pathnames/directory structure */
262- if (negative)
263- uO.jflag = FALSE, negative = 0;
264-@@ -1591,6 +1650,35 @@
265- } else
266- ++uO.overwrite_all;
267- break;
268-+#ifdef UNIX
269-+ case ('O'):
270-+ if (negative) {
271-+ Info(slide, 0x401, ((char *)slide,
272-+ "error: encodings can't be negated"));
273-+ return(PK_PARAM);
274-+ } else {
275-+ if(*s) { /* Handle the -Ocharset case */
276-+ /* Assume that charsets can't start with a dash to spot arguments misuse */
277-+ if(*s == '-') {
278-+ Info(slide, 0x401, ((char *)slide,
279-+ "error: a valid character encoding should follow the -I argument"));
280-+ return(PK_PARAM);
281-+ }
282-+ strncpy(OEM_CP, s, sizeof(OEM_CP));
283-+ } else { /* -O charset */
284-+ ++argv;
285-+ if(!(--argc > 0 && *argv != NULL && **argv != '-')) {
286-+ Info(slide, 0x401, ((char *)slide,
287-+ "error: a valid character encoding should follow the -O argument"));
288-+ return(PK_PARAM);
289-+ }
290-+ s = *argv;
291-+ strncpy(OEM_CP, s, sizeof(OEM_CP));
292-+ }
293-+ while(*(++s)); /* No params straight after charset name */
294-+ }
295-+ break;
296-+#endif /* ?UNIX */
297- case ('p'): /* pipes: extract to stdout, no messages */
298- if (negative) {
299- uO.cflag = FALSE;
300-Index: unzip-6.0/unzpriv.h
301-===================================================================
302---- unzip-6.0.orig/unzpriv.h 2015-02-11 08:46:43.675324290 -0500
303-+++ unzip-6.0/unzpriv.h 2015-02-11 08:46:43.675324290 -0500
304-@@ -3008,7 +3008,7 @@
305- !(((islochdr) || (isuxatt)) && \
306- ((hostver) == 25 || (hostver) == 26 || (hostver) == 40))) || \
307- (hostnum) == FS_HPFS_ || \
308-- ((hostnum) == FS_NTFS_ && (hostver) == 50)) { \
309-+ ((hostnum) == FS_NTFS_ /* && (hostver) == 50 */ )) { \
310- _OEM_INTERN((string)); \
311- } else { \
312- _ISO_INTERN((string)); \
313-Index: unzip-6.0/zipinfo.c
314-===================================================================
315---- unzip-6.0.orig/zipinfo.c 2015-02-11 08:46:43.675324290 -0500
316-+++ unzip-6.0/zipinfo.c 2015-02-11 08:46:43.675324290 -0500
317-@@ -457,6 +457,10 @@
318- int tflag_slm=TRUE, tflag_2v=FALSE;
319- int explicit_h=FALSE, explicit_t=FALSE;
320-
321-+#ifdef UNIX
322-+ extern char OEM_CP[MAX_CP_NAME];
323-+ extern char ISO_CP[MAX_CP_NAME];
324-+#endif
325-
326- #ifdef MACOS
327- uO.lflag = LFLAG; /* reset default on each call */
328-@@ -501,6 +505,35 @@
329- uO.lflag = 0;
330- }
331- break;
332-+#ifdef UNIX
333-+ case ('I'):
334-+ if (negative) {
335-+ Info(slide, 0x401, ((char *)slide,
336-+ "error: encodings can't be negated"));
337-+ return(PK_PARAM);
338-+ } else {
339-+ if(*s) { /* Handle the -Icharset case */
340-+ /* Assume that charsets can't start with a dash to spot arguments misuse */
341-+ if(*s == '-') {
342-+ Info(slide, 0x401, ((char *)slide,
343-+ "error: a valid character encoding should follow the -I argument"));
344-+ return(PK_PARAM);
345-+ }
346-+ strncpy(ISO_CP, s, sizeof(ISO_CP));
347-+ } else { /* -I charset */
348-+ ++argv;
349-+ if(!(--argc > 0 && *argv != NULL && **argv != '-')) {
350-+ Info(slide, 0x401, ((char *)slide,
351-+ "error: a valid character encoding should follow the -I argument"));
352-+ return(PK_PARAM);
353-+ }
354-+ s = *argv;
355-+ strncpy(ISO_CP, s, sizeof(ISO_CP));
356-+ }
357-+ while(*(++s)); /* No params straight after charset name */
358-+ }
359-+ break;
360-+#endif /* ?UNIX */
361- case 'l': /* longer form of "ls -l" type listing */
362- if (negative)
363- uO.lflag = -2, negative = 0;
364-@@ -521,6 +554,35 @@
365- G.M_flag = TRUE;
366- break;
367- #endif
368-+#ifdef UNIX
369-+ case ('O'):
370-+ if (negative) {
371-+ Info(slide, 0x401, ((char *)slide,
372-+ "error: encodings can't be negated"));
373-+ return(PK_PARAM);
374-+ } else {
375-+ if(*s) { /* Handle the -Ocharset case */
376-+ /* Assume that charsets can't start with a dash to spot arguments misuse */
377-+ if(*s == '-') {
378-+ Info(slide, 0x401, ((char *)slide,
379-+ "error: a valid character encoding should follow the -I argument"));
380-+ return(PK_PARAM);
381-+ }
382-+ strncpy(OEM_CP, s, sizeof(OEM_CP));
383-+ } else { /* -O charset */
384-+ ++argv;
385-+ if(!(--argc > 0 && *argv != NULL && **argv != '-')) {
386-+ Info(slide, 0x401, ((char *)slide,
387-+ "error: a valid character encoding should follow the -O argument"));
388-+ return(PK_PARAM);
389-+ }
390-+ s = *argv;
391-+ strncpy(OEM_CP, s, sizeof(OEM_CP));
392-+ }
393-+ while(*(++s)); /* No params straight after charset name */
394-+ }
395-+ break;
396-+#endif /* ?UNIX */
397- case 's': /* default: shorter "ls -l" type listing */
398- if (negative)
399- uO.lflag = -2, negative = 0;
1@@ -1,12 +0,0 @@
2-diff -up unzip60/zipinfo.c.attribs-overflow unzip60/zipinfo.c
3---- unzip60/zipinfo.c.attribs-overflow 2009-11-30 09:55:39.000000000 +0100
4-+++ unzip60/zipinfo.c 2009-11-30 09:56:42.844263244 +0100
5-@@ -1881,7 +1881,7 @@ static int zi_short(__G) /* return PK-
6- #endif
7- int k, error, error_in_archive=PK_COOL;
8- unsigned hostnum, hostver, methid, methnum, xattr;
9-- char *p, workspace[12], attribs[16];
10-+ char *p, workspace[12], attribs[17];
11- char methbuf[5];
12- static ZCONST char dtype[5]="NXFS"; /* normal, maximum, fast, superfast */
13- static ZCONST char Far os[NUM_HOSTS+1][4] = {
1@@ -1,30 +0,0 @@
2-diff -up unzip60/unix/configure.bzip2-configure unzip60/unix/configure
3---- unzip60/unix/configure.bzip2-configure 2009-04-16 21:25:12.000000000 +0200
4-+++ unzip60/unix/configure 2009-11-18 11:22:14.598389194 +0100
5-@@ -640,7 +640,24 @@ else
6- D_USE_BZ2="-DUSE_BZIP2"
7- L_BZ2="${BZLF} -lbz2"
8- else
9-- echo "-- bzip2 sources not found - no bzip2 support"
10-+ echo " Check if OS already has bzip2 library installed"
11-+ cat > conftest.c << _EOF_
12-+#include "bzlib.h"
13-+int main()
14-+{
15-+ bz_stream strm;
16-+ BZ2_bzCompressEnd(&strm);
17-+ return 0;
18-+}
19-+_EOF_
20-+ $CC $CFLAGS -o conftest conftest.c -lbz2 > /dev/null 2>/dev/null
21-+ if test $? -eq 0; then
22-+ echo "-- OS supports bzip2 - linking in bzip2"
23-+ D_USE_BZ2="-DUSE_BZIP2"
24-+ L_BZ2="${BZLF} -lbz2"
25-+ else
26-+ echo "-- Either bzlib.h or libbz2.a not found - no bzip2"
27-+ fi
28- fi
29- fi
30-
31-
1@@ -1,131 +0,0 @@
2-diff --git a/match.c b/match.c
3-index 6cd656f..4e569f5 100644
4---- a/match.c
5-+++ b/match.c
6-@@ -190,10 +190,10 @@ char *___tmp_ptr;
7-
8- #endif
9-
10--static int recmatch(p, s, cs)
11-+static int recmatch(p, s, ci)
12- ZCONST char *p; /* sh pattern to match */
13- ZCONST char *s; /* string to match it to */
14--int cs; /* flag: force case-sensitive matching */
15-+int ci; /* flag: force case-insensitive matching */
16- /* Recursively compare the sh pattern p with the string s and return 1 if
17- they match, and 0 or 2 if they don't or if there is a syntax error in the
18- pattern. This routine recurses on itself no deeper than the number of
19-@@ -214,7 +214,7 @@ int cs; /* flag: force case-sensitive matching */
20- if (CLEN(p) == 2) {
21- if (CLEN(s) == 2) {
22- return (*p == *s && *(p+1) == *(s+1)) ?
23-- recmatch(p + 2, s + 2, cs) : 0;
24-+ recmatch(p + 2, s + 2, ci) : 0;
25- } else {
26- return 0;
27- }
28-@@ -230,9 +230,9 @@ int cs; /* flag: force case-sensitive matching */
29- /* '?' (or '%' or '#') matches any character (but not an empty string) */
30- if (c == WILDCHR_SINGLE) {
31- if (wild_stop_at_dir)
32-- return (*s && *s != DIRSEP_CHR) ? recmatch(p, s + CLEN(s), cs) : 0;
33-+ return (*s && *s != DIRSEP_CHR) ? recmatch(p, s + CLEN(s), ci) : 0;
34- else
35-- return *s ? recmatch(p, s + CLEN(s), cs) : 0;
36-+ return *s ? recmatch(p, s + CLEN(s), ci) : 0;
37- }
38-
39- /* WILDCHR_MULTI ('*') matches any number of characters, including zero */
40-@@ -253,14 +253,14 @@ int cs; /* flag: force case-sensitive matching */
41- # endif /* ?AMIGA */
42- /* Single WILDCHR_MULTI ('*'): this doesn't match slashes */
43- for (; *s && *s != DIRSEP_CHR; INCSTR(s))
44-- if ((c = recmatch(p, s, cs)) != 0)
45-+ if ((c = recmatch(p, s, ci)) != 0)
46- return c;
47- /* end of pattern: matched if at end of string, else continue */
48- if (*p == 0)
49- return (*s == 0);
50- /* continue to match if at DIRSEP_CHR in pattern, else give up */
51- return (*p == DIRSEP_CHR || (*p == '\\' && p[1] == DIRSEP_CHR))
52-- ? recmatch(p, s, cs) : 2;
53-+ ? recmatch(p, s, ci) : 2;
54- }
55- /* Two consecutive WILDCHR_MULTI ("**"): this matches DIRSEP_CHR ('/') */
56- p++; /* move p past the second WILDCHR_MULTI */
57-@@ -308,17 +308,17 @@ int cs; /* flag: force case-sensitive matching */
58- */
59- if (q != srest)
60- return 0;
61-- return ((cs ? strcmp(p, q) : namecmp(p, q)) == 0);
62-+ return ((!ci ? strcmp(p, q) : namecmp(p, q)) == 0);
63- }
64- #else /* !_MBCS */
65-- return ((cs ? strcmp(p, srest) : namecmp(p, srest)) == 0);
66-+ return ((!ci ? strcmp(p, srest) : namecmp(p, srest)) == 0);
67- #endif /* ?_MBCS */
68- }
69- else
70- {
71- /* pattern contains more wildcards, continue with recursion... */
72- for (; *s; INCSTR(s))
73-- if ((c = recmatch(p, s, cs)) != 0)
74-+ if ((c = recmatch(p, s, ci)) != 0)
75- return c;
76- return 2; /* 2 means give up--shmatch will return false */
77- }
78-@@ -353,17 +353,17 @@ int cs; /* flag: force case-sensitive matching */
79- c = *(p-1);
80- else
81- {
82-- uch cc = (cs ? (uch)*s : case_map((uch)*s));
83-+ uch cc = (!ci ? (uch)*s : to_up((uch)*s));
84- uch uc = (uch) c;
85- if (*(p+1) != '-')
86- for (uc = uc ? uc : (uch)*p; uc <= (uch)*p; uc++)
87- /* compare range */
88-- if ((cs ? uc : case_map(uc)) == cc)
89-- return r ? 0 : recmatch(q + CLEN(q), s + CLEN(s), cs);
90-+ if ((!ci ? uc : to_up(uc)) == cc)
91-+ return r ? 0 : recmatch(q + CLEN(q), s + CLEN(s), ci);
92- c = e = 0; /* clear range, escape flags */
93- }
94- }
95-- return r ? recmatch(q + CLEN(q), s + CLEN(s), cs) : 0;
96-+ return r ? recmatch(q + CLEN(q), s + CLEN(s), ci) : 0;
97- /* bracket match failed */
98- }
99- #endif /* !VMS */
100-@@ -382,18 +382,18 @@ int cs; /* flag: force case-sensitive matching */
101- {
102- /* Match "...]" with "]". Continue after "]" in both. */
103- if ((*(p+ 2* CLEN( p)) == ']') && (*s == ']'))
104-- return recmatch( (p+ 3* CLEN( p)), (s+ CLEN( s)), cs);
105-+ return recmatch( (p+ 3* CLEN( p)), (s+ CLEN( s)), ci);
106-
107- /* Else, look for a reduced match in s, until "]" in or end of s. */
108- for (; *s && (*s != ']'); INCSTR(s))
109- if (*s == '.')
110- /* If reduced match, then continue after "..." in p, "." in s. */
111-- if ((c = recmatch( (p+ CLEN( p)), s, cs)) != 0)
112-+ if ((c = recmatch( (p+ CLEN( p)), s, ci)) != 0)
113- return (int)c;
114-
115- /* Match "...]" with "]". Continue after "]" in both. */
116- if ((*(p+ 2* CLEN( p)) == ']') && (*s == ']'))
117-- return recmatch( (p+ 3* CLEN( p)), (s+ CLEN( s)), cs);
118-+ return recmatch( (p+ 3* CLEN( p)), (s+ CLEN( s)), ci);
119-
120- /* No reduced match. Quit. */
121- return 2;
122-@@ -402,8 +402,8 @@ int cs; /* flag: force case-sensitive matching */
123- #endif /* def VMS */
124-
125- /* Just a character--compare it */
126-- return (cs ? c == *s : case_map((uch)c) == case_map((uch)*s)) ?
127-- recmatch(p, s + CLEN(s), cs) : 0;
128-+ return (!ci ? c == *s : to_up((uch)c) == to_up((uch)*s)) ?
129-+ recmatch(p, s + CLEN(s), ci) : 0;
130- }
131-
132-
+0,
-176
1@@ -1,176 +0,0 @@
2-diff -up unzip60/extract.c.close unzip60/extract.c
3---- unzip60/extract.c.close 2009-03-14 02:32:52.000000000 +0100
4-+++ unzip60/extract.c 2009-11-19 08:17:23.481263496 +0100
5-@@ -1924,24 +1924,21 @@ static int extract_or_test_member(__G)
6-
7- #ifdef VMS /* VMS: required even for stdout! (final flush) */
8- if (!uO.tflag) /* don't close NULL file */
9-- close_outfile(__G);
10-+ error = close_outfile(__G);
11- #else
12- #ifdef DLL
13- if (!uO.tflag && (!uO.cflag || G.redirect_data)) {
14- if (G.redirect_data)
15- FINISH_REDIRECT();
16- else
17-- close_outfile(__G);
18-+ error = close_outfile(__G);
19- }
20- #else
21- if (!uO.tflag && !uO.cflag) /* don't close NULL file or stdout */
22-- close_outfile(__G);
23-+ error = close_outfile(__G);
24- #endif
25- #endif /* VMS */
26-
27-- /* GRR: CONVERT close_outfile() TO NON-VOID: CHECK FOR ERRORS! */
28--
29--
30- if (G.disk_full) { /* set by flush() */
31- if (G.disk_full > 1) {
32- #if (defined(DELETE_IF_FULL) && defined(HAVE_UNLINK))
33-diff -up unzip60/unix/unix.c.close unzip60/unix/unix.c
34---- unzip60/unix/unix.c.close 2009-01-24 00:31:26.000000000 +0100
35-+++ unzip60/unix/unix.c 2009-11-19 08:33:25.568389171 +0100
36-@@ -1096,10 +1096,41 @@ static int get_extattribs(__G__ pzt, z_u
37- #ifndef MTS
38-
39- /****************************/
40-+/* Function CloseError() */
41-+/***************************/
42-+
43-+int CloseError(__G)
44-+ __GDEF
45-+{
46-+ int errval = PK_OK;
47-+
48-+ if (fclose(G.outfile) < 0) {
49-+ switch (errno) {
50-+ case ENOSPC:
51-+ /* Do we need this on fileio.c? */
52-+ Info(slide, 0x4a1, ((char *)slide, "%s: write error (disk full?). Continue? (y/n/^C) ",
53-+ FnFilter1(G.filename)));
54-+ fgets(G.answerbuf, 9, stdin);
55-+ if (*G.answerbuf == 'y') /* stop writing to this file */
56-+ G.disk_full = 1; /* pass to next */
57-+ else
58-+ G.disk_full = 2; /* no: exit program */
59-+
60-+ errval = PK_DISK;
61-+ break;
62-+
63-+ default:
64-+ errval = PK_WARN;
65-+ }
66-+ }
67-+ return errval;
68-+} /* End of CloseError() */
69-+
70-+/****************************/
71- /* Function close_outfile() */
72- /****************************/
73-
74--void close_outfile(__G) /* GRR: change to return PK-style warning level */
75-+int close_outfile(__G)
76- __GDEF
77- {
78- union {
79-@@ -1108,6 +1139,7 @@ void close_outfile(__G) /* GRR: chang
80- } zt;
81- ulg z_uidgid[2];
82- int have_uidgid_flg;
83-+ int errval = PK_OK;
84-
85- have_uidgid_flg = get_extattribs(__G__ &(zt.t3), z_uidgid);
86-
87-@@ -1141,16 +1173,16 @@ void close_outfile(__G) /* GRR: chang
88- Info(slide, 0x201, ((char *)slide,
89- "warning: symbolic link (%s) failed: mem alloc overflow\n",
90- FnFilter1(G.filename)));
91-- fclose(G.outfile);
92-- return;
93-+ errval = CloseError(G.outfile, G.filename);
94-+ return errval ? errval : PK_WARN;
95- }
96-
97- if ((slnk_entry = (slinkentry *)malloc(slnk_entrysize)) == NULL) {
98- Info(slide, 0x201, ((char *)slide,
99- "warning: symbolic link (%s) failed: no mem\n",
100- FnFilter1(G.filename)));
101-- fclose(G.outfile);
102-- return;
103-+ errval = CloseError(G.outfile, G.filename);
104-+ return errval ? errval : PK_WARN;
105- }
106- slnk_entry->next = NULL;
107- slnk_entry->targetlen = ucsize;
108-@@ -1174,10 +1206,10 @@ void close_outfile(__G) /* GRR: chang
109- "warning: symbolic link (%s) failed\n",
110- FnFilter1(G.filename)));
111- free(slnk_entry);
112-- fclose(G.outfile);
113-- return;
114-+ errval = CloseError(G.outfile, G.filename);
115-+ return errval ? errval : PK_WARN;
116- }
117-- fclose(G.outfile); /* close "link" file for good... */
118-+ errval = CloseError(G.outfile, G.filename); /* close "link" file for good... */
119- slnk_entry->target[ucsize] = '\0';
120- if (QCOND2)
121- Info(slide, 0, ((char *)slide, "-> %s ",
122-@@ -1188,7 +1220,7 @@ void close_outfile(__G) /* GRR: chang
123- else
124- G.slink_head = slnk_entry;
125- G.slink_last = slnk_entry;
126-- return;
127-+ return errval;
128- }
129- #endif /* SYMLINKS */
130-
131-@@ -1201,7 +1233,7 @@ void close_outfile(__G) /* GRR: chang
132- #endif
133-
134- #if (defined(NO_FCHOWN))
135-- fclose(G.outfile);
136-+ errval = CloseError(G.outfile, G.filename);
137- #endif
138-
139- /* if -X option was specified and we have UID/GID info, restore it */
140-@@ -1227,7 +1259,7 @@ void close_outfile(__G) /* GRR: chang
141- }
142-
143- #if (!defined(NO_FCHOWN) && defined(NO_FCHMOD))
144-- fclose(G.outfile);
145-+ errval = CloseError(G.outfile, G.filename);
146- #endif
147-
148- #if (!defined(NO_FCHOWN) && !defined(NO_FCHMOD))
149-@@ -1239,7 +1271,7 @@ void close_outfile(__G) /* GRR: chang
150- if (fchmod(fileno(G.outfile), filtattr(__G__ G.pInfo->file_attr)))
151- perror("fchmod (file attributes) error");
152-
153-- fclose(G.outfile);
154-+ errval = CloseError(G.outfile, G.filename);
155- #endif /* !NO_FCHOWN && !NO_FCHMOD */
156-
157- /* skip restoring time stamps on user's request */
158-@@ -1267,6 +1299,7 @@ void close_outfile(__G) /* GRR: chang
159- #endif
160- #endif /* NO_FCHOWN || NO_FCHMOD */
161-
162-+ return errval;
163- } /* end function close_outfile() */
164-
165- #endif /* !MTS */
166-diff -up unzip60/unzpriv.h.close unzip60/unzpriv.h
167---- unzip60/unzpriv.h.close 2009-04-20 01:59:26.000000000 +0200
168-+++ unzip60/unzpriv.h 2009-11-19 08:19:08.610388618 +0100
169-@@ -2604,7 +2604,7 @@ char *GetLoadPath OF((__GPRO));
170- int SetFileSize OF((FILE *file, zusz_t filesize)); /* local */
171- #endif
172- #ifndef MTS /* macro in MTS */
173-- void close_outfile OF((__GPRO)); /* local */
174-+ int close_outfile OF((__GPRO)); /* local */
175- #endif
176- #ifdef SET_SYMLINK_ATTRIBS
177- int set_symlnk_attribs OF((__GPRO__ slinkentry *slnk_entry)); /* local */
1@@ -1,12 +0,0 @@
2-diff -up unzip60/unix/configure.nostrip unzip60/unix/configure
3---- unzip60/unix/configure.nostrip 2009-11-30 10:18:09.000000000 +0100
4-+++ unzip60/unix/configure 2009-11-30 10:21:08.354264213 +0100
5-@@ -17,7 +17,7 @@ CFLAGSR=${CFLAGS}
6- IZ_BZIP2=${3}
7- CFLAGS="${CFLAGS} -I. -DUNIX"
8- LFLAGS1=""
9--LFLAGS2="-s"
10-+LFLAGS2="${LFLAGS2}"
11- LN="ln -s"
12-
13- CFLAGS_OPT=''
1@@ -1,35 +0,0 @@
2---- unzip60/list.c
3-+++ unzip60/list.c
4-@@ -97,7 +97,7 @@ int list_files(__G) /* return PK-type
5- {
6- int do_this_file=FALSE, cfactor, error, error_in_archive=PK_COOL;
7- #ifndef WINDLL
8-- char sgn, cfactorstr[13];
9-+ char sgn, cfactorstr[1+10+1+1]; /* <sgn><int>%NUL */
10- int longhdr=(uO.vflag>1);
11- #endif
12- int date_format;
13-@@ -389,9 +389,9 @@ int list_files(__G) /* return PK-type
14- }
15- #else /* !WINDLL */
16- if (cfactor == 100)
17-- sprintf(cfactorstr, LoadFarString(CompFactor100));
18-+ snprintf(cfactorstr, sizeof(cfactorstr), LoadFarString(CompFactor100));
19- else
20-- sprintf(cfactorstr, LoadFarString(CompFactorStr), sgn, cfactor);
21-+ snprintf(cfactorstr, sizeof(cfactorstr), LoadFarString(CompFactorStr), sgn, cfactor);
22- if (longhdr)
23- Info(slide, 0, ((char *)slide, LoadFarString(LongHdrStats),
24- FmZofft(G.crec.ucsize, "8", "u"), methbuf,
25-@@ -471,9 +471,9 @@ int list_files(__G) /* return PK-type
26-
27- #else /* !WINDLL */
28- if (cfactor == 100)
29-- sprintf(cfactorstr, LoadFarString(CompFactor100));
30-+ snprintf(cfactorstr, sizeof(cfactorstr), LoadFarString(CompFactor100));
31- else
32-- sprintf(cfactorstr, LoadFarString(CompFactorStr), sgn, cfactor);
33-+ snprintf(cfactorstr, sizeof(cfactorstr), LoadFarString(CompFactorStr), sgn, cfactor);
34- if (longhdr) {
35- Info(slide, 0, ((char *)slide, LoadFarString(LongFileTrailer),
36- FmZofft(tot_ucsize, "8", "u"), FmZofft(tot_csize, "8", "u"),
1@@ -1,477 +0,0 @@
2-diff -up unzip60/match.c.recmatch unzip60/match.c
3---- unzip60/match.c.recmatch 2005-08-14 13:00:36.000000000 -0400
4-+++ unzip60/match.c 2013-05-28 10:29:57.949077543 -0400
5-@@ -27,16 +27,14 @@
6-
7- ---------------------------------------------------------------------------
8-
9-- Copyright on recmatch() from Zip's util.c (although recmatch() was almost
10-- certainly written by Mark Adler...ask me how I can tell :-) ):
11-+ Copyright on recmatch() from Zip's util.c
12-+ Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
13-
14-- Copyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-loup Gailly,
15-- Kai Uwe Rommel and Igor Mandrichenko.
16-+ See the accompanying file LICENSE, version 2004-May-22 or later
17-+ for terms of use.
18-+ If, for some reason, both of these files are missing, the Info-ZIP license
19-+ also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
20-
21-- Permission is granted to any individual or institution to use, copy,
22-- or redistribute this software so long as all of the original files are
23-- included unmodified, that it is not sold for profit, and that this copy-
24-- right notice is retained.
25-
26- ---------------------------------------------------------------------------
27-
28-@@ -53,7 +51,7 @@
29-
30- A set is composed of characters or ranges; a range looks like ``character
31- hyphen character'' (as in 0-9 or A-Z). [0-9a-zA-Z_] is the minimal set of
32-- characters allowed in the [..] pattern construct. Other characters are
33-+ characters ALlowed in the [..] pattern construct. Other characters are
34- allowed (i.e., 8-bit characters) if your system will support them.
35-
36- To suppress the special syntactic significance of any of ``[]*?!^-\'', in-
37-@@ -101,8 +99,32 @@
38- # define WILDCHAR '?'
39- # define BEG_RANGE '['
40- # define END_RANGE ']'
41-+# define WILDCHR_SINGLE '?'
42-+# define DIRSEP_CHR '/'
43-+# define WILDCHR_MULTI '*'
44- #endif
45-
46-+#ifdef WILD_STOP_AT_DIR
47-+ int wild_stop_at_dir = 1; /* default wildcards do not include / in matches */
48-+#else
49-+ int wild_stop_at_dir = 0; /* default wildcards do include / in matches */
50-+#endif
51-+
52-+
53-+
54-+/*
55-+ * case mapping functions. case_map is used to ignore case in comparisons,
56-+ * to_up is used to force upper case even on Unix (for dosify option).
57-+ */
58-+#ifdef USE_CASE_MAP
59-+# define case_map(c) upper[(c) & 0xff]
60-+# define to_up(c) upper[(c) & 0xff]
61-+#else
62-+# define case_map(c) (c)
63-+# define to_up(c) ((c) >= 'a' && (c) <= 'z' ? (c)-'a'+'A' : (c))
64-+#endif /* USE_CASE_MAP */
65-+
66-+
67- #if 0 /* GRR: add this to unzip.h someday... */
68- #if !(defined(MSDOS) && defined(DOSWILD))
69- #ifdef WILD_STOP_AT_DIR
70-@@ -114,8 +136,8 @@ int recmatch OF((ZCONST uch *pattern, ZC
71- int ignore_case __WDLPRO));
72- #endif
73- #endif /* 0 */
74--static int recmatch OF((ZCONST uch *pattern, ZCONST uch *string,
75-- int ignore_case __WDLPRO));
76-+static int recmatch OF((ZCONST char *, ZCONST char *,
77-+ int));
78- static char *isshexp OF((ZCONST char *p));
79- static int namecmp OF((ZCONST char *s1, ZCONST char *s2));
80-
81-@@ -154,192 +176,240 @@ int match(string, pattern, ignore_case _
82- }
83- dospattern[j-1] = '\0'; /* nuke the end "." */
84- }
85-- j = recmatch((uch *)dospattern, (uch *)string, ignore_case __WDL);
86-+ j = recmatch(dospattern, string, ignore_case);
87- free(dospattern);
88- return j == 1;
89- } else
90- #endif /* MSDOS && DOSWILD */
91-- return recmatch((uch *)pattern, (uch *)string, ignore_case __WDL) == 1;
92-+ return recmatch(pattern, string, ignore_case) == 1;
93- }
94-
95-+#ifdef _MBCS
96-+
97-+char *___tmp_ptr;
98-
99-+#endif
100-
101--static int recmatch(p, s, ic __WDL)
102-- ZCONST uch *p; /* sh pattern to match */
103-- ZCONST uch *s; /* string to which to match it */
104-- int ic; /* true for case insensitivity */
105-- __WDLDEF /* directory sepchar for WildStopAtDir mode, or 0 */
106-+static int recmatch(p, s, cs)
107-+ZCONST char *p; /* sh pattern to match */
108-+ZCONST char *s; /* string to match it to */
109-+int cs; /* flag: force case-sensitive matching */
110- /* Recursively compare the sh pattern p with the string s and return 1 if
111-- * they match, and 0 or 2 if they don't or if there is a syntax error in the
112-- * pattern. This routine recurses on itself no more deeply than the number
113-- * of characters in the pattern. */
114-+ they match, and 0 or 2 if they don't or if there is a syntax error in the
115-+ pattern. This routine recurses on itself no deeper than the number of
116-+ characters in the pattern. */
117- {
118-- unsigned int c; /* pattern char or start of range in [-] loop */
119-+ int c; /* pattern char or start of range in [-] loop */
120-+ /* Get first character, the pattern for new recmatch calls follows */
121-+ /* borrowed from Zip's global.c */
122-+ int no_wild = 0;
123-+ int allow_regex=1;
124-+ /* This fix provided by akt@m5.dion.ne.jp for Japanese.
125-+ See 21 July 2006 mail.
126-+ It only applies when p is pointing to a doublebyte character and
127-+ things like / and wildcards are not doublebyte. This probably
128-+ should not be needed. */
129-
130-- /* Get first character, the pattern for new recmatch calls follows */
131-- c = *p; INCSTR(p);
132-+#ifdef _MBCS
133-+ if (CLEN(p) == 2) {
134-+ if (CLEN(s) == 2) {
135-+ return (*p == *s && *(p+1) == *(s+1)) ?
136-+ recmatch(p + 2, s + 2, cs) : 0;
137-+ } else {
138-+ return 0;
139-+ }
140-+ }
141-+#endif /* ?_MBCS */
142-
143-- /* If that was the end of the pattern, match if string empty too */
144-- if (c == 0)
145-- return *s == 0;
146-+ c = *POSTINCSTR(p);
147-
148-- /* '?' (or '%') matches any character (but not an empty string). */
149-- if (c == WILDCHAR)
150--#ifdef WILD_STOP_AT_DIR
151-- /* If uO.W_flag is non-zero, it won't match '/' */
152-- return (*s && (!sepc || *s != (uch)sepc))
153-- ? recmatch(p, s + CLEN(s), ic, sepc) : 0;
154--#else
155-- return *s ? recmatch(p, s + CLEN(s), ic) : 0;
156--#endif
157-+ /* If that was the end of the pattern, match if string empty too */
158-+ if (c == 0)
159-+ return *s == 0;
160-+
161-+ /* '?' (or '%' or '#') matches any character (but not an empty string) */
162-+ if (c == WILDCHR_SINGLE) {
163-+ if (wild_stop_at_dir)
164-+ return (*s && *s != DIRSEP_CHR) ? recmatch(p, s + CLEN(s), cs) : 0;
165-+ else
166-+ return *s ? recmatch(p, s + CLEN(s), cs) : 0;
167-+ }
168-
169-- /* '*' matches any number of characters, including zero */
170-+ /* WILDCHR_MULTI ('*') matches any number of characters, including zero */
171- #ifdef AMIGA
172-- if (c == '#' && *p == '?') /* "#?" is Amiga-ese for "*" */
173-- c = '*', p++;
174-+ if (!no_wild && c == '#' && *p == '?') /* "#?" is Amiga-ese for "*" */
175-+ c = WILDCHR_MULTI, p++;
176- #endif /* AMIGA */
177-- if (c == '*') {
178--#ifdef WILD_STOP_AT_DIR
179-- if (sepc) {
180-- /* check for single "*" or double "**" */
181--# ifdef AMIGA
182-- if ((c = p[0]) == '#' && p[1] == '?') /* "#?" is Amiga-ese for "*" */
183-- c = '*', p++;
184-- if (c != '*') {
185--# else /* !AMIGA */
186-- if (*p != '*') {
187--# endif /* ?AMIGA */
188-- /* single "*": this doesn't match the dirsep character */
189-- for (; *s && *s != (uch)sepc; INCSTR(s))
190-- if ((c = recmatch(p, s, ic, sepc)) != 0)
191-- return (int)c;
192-- /* end of pattern: matched if at end of string, else continue */
193-- if (*p == '\0')
194-- return (*s == 0);
195-- /* continue to match if at sepc in pattern, else give up */
196-- return (*p == (uch)sepc || (*p == '\\' && p[1] == (uch)sepc))
197-- ? recmatch(p, s, ic, sepc) : 2;
198-- }
199-- /* "**": this matches slashes */
200-- ++p; /* move p behind the second '*' */
201-- /* and continue with the non-W_flag code variant */
202-- }
203--#endif /* WILD_STOP_AT_DIR */
204-+ if (!no_wild && c == WILDCHR_MULTI)
205-+ {
206-+ if (wild_stop_at_dir) {
207-+ /* Check for an immediately following WILDCHR_MULTI */
208-+# ifdef AMIGA
209-+ if ((c = p[0]) == '#' && p[1] == '?') /* "#?" is Amiga-ese for "*" */
210-+ c = WILDCHR_MULTI, p++;
211-+ if (c != WILDCHR_MULTI) {
212-+# else /* !AMIGA */
213-+ if (*p != WILDCHR_MULTI) {
214-+# endif /* ?AMIGA */
215-+ /* Single WILDCHR_MULTI ('*'): this doesn't match slashes */
216-+ for (; *s && *s != DIRSEP_CHR; INCSTR(s))
217-+ if ((c = recmatch(p, s, cs)) != 0)
218-+ return c;
219-+ /* end of pattern: matched if at end of string, else continue */
220- if (*p == 0)
221-- return 1;
222-- if (isshexp((ZCONST char *)p) == NULL) {
223-- /* Optimization for rest of pattern being a literal string:
224-- * If there are no other shell expression chars in the rest
225-- * of the pattern behind the multi-char wildcard, then just
226-- * compare the literal string tail.
227-- */
228-- ZCONST uch *srest;
229--
230-- srest = s + (strlen((ZCONST char *)s) - strlen((ZCONST char *)p));
231-- if (srest - s < 0)
232-- /* remaining literal string from pattern is longer than rest
233-- * of test string, there can't be a match
234-- */
235-- return 0;
236-- else
237-- /* compare the remaining literal pattern string with the last
238-- * bytes of the test string to check for a match
239-- */
240-+ return (*s == 0);
241-+ /* continue to match if at DIRSEP_CHR in pattern, else give up */
242-+ return (*p == DIRSEP_CHR || (*p == '\\' && p[1] == DIRSEP_CHR))
243-+ ? recmatch(p, s, cs) : 2;
244-+ }
245-+ /* Two consecutive WILDCHR_MULTI ("**"): this matches DIRSEP_CHR ('/') */
246-+ p++; /* move p past the second WILDCHR_MULTI */
247-+ /* continue with the normal non-WILD_STOP_AT_DIR code */
248-+ } /* wild_stop_at_dir */
249-+
250-+ /* Not wild_stop_at_dir */
251-+ if (*p == 0)
252-+ return 1;
253-+ if (!isshexp((char *)p))
254-+ {
255-+ /* optimization for rest of pattern being a literal string */
256-+
257-+ /* optimization to handle patterns like *.txt */
258-+ /* if the first char in the pattern is '*' and there */
259-+ /* are no other shell expression chars, i.e. a literal string */
260-+ /* then just compare the literal string at the end */
261-+
262-+ ZCONST char *srest;
263-+
264-+ srest = s + (strlen(s) - strlen(p));
265-+ if (srest - s < 0)
266-+ /* remaining literal string from pattern is longer than rest of
267-+ test string, there can't be a match
268-+ */
269-+ return 0;
270-+ else
271-+ /* compare the remaining literal pattern string with the last bytes
272-+ of the test string to check for a match */
273- #ifdef _MBCS
274-- {
275-- ZCONST uch *q = s;
276-+ {
277-+ ZCONST char *q = s;
278-
279-- /* MBCS-aware code must not scan backwards into a string from
280-- * the end.
281-- * So, we have to move forward by character from our well-known
282-- * character position s in the test string until we have
283-- * advanced to the srest position.
284-- */
285-- while (q < srest)
286-- INCSTR(q);
287-- /* In case the byte *srest is a trailing byte of a multibyte
288-- * character in the test string s, we have actually advanced
289-- * past the position (srest).
290-- * For this case, the match has failed!
291-- */
292-- if (q != srest)
293-- return 0;
294-- return ((ic
295-- ? namecmp((ZCONST char *)p, (ZCONST char *)q)
296-- : strcmp((ZCONST char *)p, (ZCONST char *)q)
297-- ) == 0);
298-- }
299-+ /* MBCS-aware code must not scan backwards into a string from
300-+ * the end.
301-+ * So, we have to move forward by character from our well-known
302-+ * character position s in the test string until we have advanced
303-+ * to the srest position.
304-+ */
305-+ while (q < srest)
306-+ INCSTR(q);
307-+ /* In case the byte *srest is a trailing byte of a multibyte
308-+ * character, we have actually advanced past the position (srest).
309-+ * For this case, the match has failed!
310-+ */
311-+ if (q != srest)
312-+ return 0;
313-+ return ((cs ? strcmp(p, q) : namecmp(p, q)) == 0);
314-+ }
315- #else /* !_MBCS */
316-- return ((ic
317-- ? namecmp((ZCONST char *)p, (ZCONST char *)srest)
318-- : strcmp((ZCONST char *)p, (ZCONST char *)srest)
319-- ) == 0);
320-+ return ((cs ? strcmp(p, srest) : namecmp(p, srest)) == 0);
321- #endif /* ?_MBCS */
322-- } else {
323-- /* pattern contains more wildcards, continue with recursion... */
324-- for (; *s; INCSTR(s))
325-- if ((c = recmatch(p, s, ic __WDL)) != 0)
326-- return (int)c;
327-- return 2; /* 2 means give up--match will return false */
328-- }
329- }
330--
331-- /* Parse and process the list of characters and ranges in brackets */
332-- if (c == BEG_RANGE) {
333-- int e; /* flag true if next char to be taken literally */
334-- ZCONST uch *q; /* pointer to end of [-] group */
335-- int r; /* flag true to match anything but the range */
336--
337-- if (*s == 0) /* need a character to match */
338-- return 0;
339-- p += (r = (*p == '!' || *p == '^')); /* see if reverse */
340-- for (q = p, e = 0; *q; INCSTR(q)) /* find closing bracket */
341-- if (e)
342-- e = 0;
343-- else
344-- if (*q == '\\') /* GRR: change to ^ for MS-DOS, OS/2? */
345-- e = 1;
346-- else if (*q == END_RANGE)
347-- break;
348-- if (*q != END_RANGE) /* nothing matches if bad syntax */
349-- return 0;
350-- for (c = 0, e = (*p == '-'); p < q; INCSTR(p)) {
351-- /* go through the list */
352-- if (!e && *p == '\\') /* set escape flag if \ */
353-- e = 1;
354-- else if (!e && *p == '-') /* set start of range if - */
355-- c = *(p-1);
356-- else {
357-- unsigned int cc = Case(*s);
358--
359-- if (*(p+1) != '-')
360-- for (c = c ? c : *p; c <= *p; c++) /* compare range */
361-- if ((unsigned)Case(c) == cc) /* typecast for MSC bug */
362-- return r ? 0 : recmatch(q + 1, s + 1, ic __WDL);
363-- c = e = 0; /* clear range, escape flags */
364-- }
365-- }
366-- return r ? recmatch(q + CLEN(q), s + CLEN(s), ic __WDL) : 0;
367-- /* bracket match failed */
368-+ else
369-+ {
370-+ /* pattern contains more wildcards, continue with recursion... */
371-+ for (; *s; INCSTR(s))
372-+ if ((c = recmatch(p, s, cs)) != 0)
373-+ return c;
374-+ return 2; /* 2 means give up--shmatch will return false */
375- }
376-+ }
377-
378-- /* if escape ('\\'), just compare next character */
379-- if (c == '\\' && (c = *p++) == 0) /* if \ at end, then syntax error */
380-- return 0;
381-+#ifndef VMS /* No bracket matching in VMS */
382-+ /* Parse and process the list of characters and ranges in brackets */
383-+ if (!no_wild && allow_regex && c == '[')
384-+ {
385-+ int e; /* flag true if next char to be taken literally */
386-+ ZCONST char *q; /* pointer to end of [-] group */
387-+ int r; /* flag true to match anything but the range */
388-+
389-+ if (*s == 0) /* need a character to match */
390-+ return 0;
391-+ p += (r = (*p == '!' || *p == '^')); /* see if reverse */
392-+ for (q = p, e = 0; *q; q++) /* find closing bracket */
393-+ if (e)
394-+ e = 0;
395-+ else
396-+ if (*q == '\\')
397-+ e = 1;
398-+ else if (*q == ']')
399-+ break;
400-+ if (*q != ']') /* nothing matches if bad syntax */
401-+ return 0;
402-+ for (c = 0, e = *p == '-'; p < q; p++) /* go through the list */
403-+ {
404-+ if (e == 0 && *p == '\\') /* set escape flag if \ */
405-+ e = 1;
406-+ else if (e == 0 && *p == '-') /* set start of range if - */
407-+ c = *(p-1);
408-+ else
409-+ {
410-+ uch cc = (cs ? (uch)*s : case_map((uch)*s));
411-+ uch uc = (uch) c;
412-+ if (*(p+1) != '-')
413-+ for (uc = uc ? uc : (uch)*p; uc <= (uch)*p; uc++)
414-+ /* compare range */
415-+ if ((cs ? uc : case_map(uc)) == cc)
416-+ return r ? 0 : recmatch(q + CLEN(q), s + CLEN(s), cs);
417-+ c = e = 0; /* clear range, escape flags */
418-+ }
419-+ }
420-+ return r ? recmatch(q + CLEN(q), s + CLEN(s), cs) : 0;
421-+ /* bracket match failed */
422-+ }
423-+#endif /* !VMS */
424-
425-- /* just a character--compare it */
426--#ifdef QDOS
427-- return QMatch(Case((uch)c), Case(*s)) ?
428-- recmatch(p, s + CLEN(s), ic __WDL) : 0;
429--#else
430-- return Case((uch)c) == Case(*s) ?
431-- recmatch(p, s + CLEN(s), ic __WDL) : 0;
432--#endif
433-+ /* If escape ('\'), just compare next character */
434-+ if (!no_wild && c == '\\')
435-+ if ((c = *p++) == '\0') /* if \ at end, then syntax error */
436-+ return 0;
437-+
438-+#ifdef VMS
439-+ /* 2005-11-06 SMS.
440-+ Handle "..." wildcard in p with "." or "]" in s.
441-+ */
442-+ if ((c == '.') && (*p == '.') && (*(p+ CLEN( p)) == '.') &&
443-+ ((*s == '.') || (*s == ']')))
444-+ {
445-+ /* Match "...]" with "]". Continue after "]" in both. */
446-+ if ((*(p+ 2* CLEN( p)) == ']') && (*s == ']'))
447-+ return recmatch( (p+ 3* CLEN( p)), (s+ CLEN( s)), cs);
448-+
449-+ /* Else, look for a reduced match in s, until "]" in or end of s. */
450-+ for (; *s && (*s != ']'); INCSTR(s))
451-+ if (*s == '.')
452-+ /* If reduced match, then continue after "..." in p, "." in s. */
453-+ if ((c = recmatch( (p+ CLEN( p)), s, cs)) != 0)
454-+ return (int)c;
455-+
456-+ /* Match "...]" with "]". Continue after "]" in both. */
457-+ if ((*(p+ 2* CLEN( p)) == ']') && (*s == ']'))
458-+ return recmatch( (p+ 3* CLEN( p)), (s+ CLEN( s)), cs);
459-+
460-+ /* No reduced match. Quit. */
461-+ return 2;
462-+ }
463-+
464-+#endif /* def VMS */
465-+
466-+ /* Just a character--compare it */
467-+ return (cs ? c == *s : case_map((uch)c) == case_map((uch)*s)) ?
468-+ recmatch(p, s + CLEN(s), cs) : 0;
469-+}
470-
471--} /* end function recmatch() */
472-
473-
474-
475-+/*************************************************************************************************/
476- static char *isshexp(p)
477- ZCONST char *p;
478- /* If p is a sh expression, a pointer to the first special character is
1@@ -1,11 +0,0 @@
2---- unzip60/man/unzip.1 2011-01-11 11:59:59.000000000 +0000
3-+++ unzip60/man/unzip.1 2011-02-05 18:45:55.000000000 +0000
4-@@ -424,7 +424,7 @@
5- .\" Amiga support possible eventually, but not yet
6- [MS-DOS, OS/2, NT] restore the volume label if the extraction medium is
7- removable (e.g., a diskette). Doubling the option (\fB\-$$\fP) allows fixed
8--media (hard disks) to be labelled as well. By default, volume labels are
9-+media (hard disks) to be labeled as well. By default, volume labels are
10- ignored.
11- .IP \fB\-/\fP\ \fIextensions\fP
12- [Acorn only] overrides the extension list supplied by Unzip$Ext environment
1@@ -1,25 +0,0 @@
2-diff --git a/extract.c b/extract.c
3-index a0a4929..9ef80b3 100644
4---- a/extract.c
5-+++ b/extract.c
6-@@ -2214,6 +2214,7 @@ static int test_compr_eb(__G__ eb, eb_size, compr_offset, test_uc_ebdata)
7- ulg eb_ucsize;
8- uch *eb_ucptr;
9- int r;
10-+ ush method;
11-
12- if (compr_offset < 4) /* field is not compressed: */
13- return PK_OK; /* do nothing and signal OK */
14-@@ -2223,6 +2224,12 @@ static int test_compr_eb(__G__ eb, eb_size, compr_offset, test_uc_ebdata)
15- eb_size <= (compr_offset + EB_CMPRHEADLEN)))
16- return IZ_EF_TRUNC; /* no compressed data! */
17-
18-+ method = makeword(eb + (EB_HEADSIZE + compr_offset));
19-+ if ((method == STORED) && (eb_size != compr_offset + EB_CMPRHEADLEN + eb_ucsize))
20-+ return PK_ERR; /* compressed & uncompressed
21-+ * should match in STORED
22-+ * method */
23-+
24- if (
25- #ifdef INT_16BIT
26- (((ulg)(extent)eb_ucsize) != eb_ucsize) ||
1@@ -1,17 +0,0 @@
2-diff --git a/process.c b/process.c
3-index 1e9a1e1..905732b 100644
4---- a/process.c
5-+++ b/process.c
6-@@ -1751,6 +1751,12 @@ int process_cdir_file_hdr(__G) /* return PK-type error code */
7- = (G.crec.general_purpose_bit_flag & (1 << 11)) == (1 << 11);
8- #endif
9-
10-+#ifdef SYMLINKS
11-+ /* Initialize the symlink flag, may be set by the platform-specific
12-+ mapattr function. */
13-+ G.pInfo->symlink = 0;
14-+#endif
15-+
16- return PK_COOL;
17-
18- } /* end function process_cdir_file_hdr() */
1@@ -1,26 +0,0 @@
2-diff --git a/fileio.c b/fileio.c
3-index ba0a1d0..03fc4be 100644
4---- a/fileio.c
5-+++ b/fileio.c
6-@@ -2006,6 +2006,7 @@ int do_string(__G__ length, option) /* return PK-type error code */
7- unsigned comment_bytes_left;
8- unsigned int block_len;
9- int error=PK_OK;
10-+ unsigned int length2;
11- #ifdef AMIGA
12- char tmp_fnote[2 * AMIGA_FILENOTELEN]; /* extra room for squozen chars */
13- #endif
14-@@ -2292,8 +2293,12 @@ int do_string(__G__ length, option) /* return PK-type error code */
15- seek_zipf(__G__ G.cur_zipfile_bufstart - G.extra_bytes +
16- (G.inptr-G.inbuf) + length);
17- } else {
18-- if (readbuf(__G__ (char *)G.extra_field, length) == 0)
19-+ if ((length2 = readbuf(__G__ (char *)G.extra_field, length)) == 0)
20- return PK_EOF;
21-+ if(length2 < length) {
22-+ memset (__G__ (char *)G.extra_field+length2, 0 , length-length2);
23-+ length = length2;
24-+ }
25- /* Looks like here is where extra fields are read */
26- getZip64Data(__G__ G.extra_field, length);
27- #ifdef UNICODE_SUPPORT
1@@ -1,19 +0,0 @@
2-diff --git a/process.c b/process.c
3-index d2a846e..cba2463 100644
4---- a/process.c
5-+++ b/process.c
6-@@ -2064,10 +2064,14 @@ int getUnicodeData(__G__ ef_buf, ef_len)
7- G.unipath_checksum = makelong(offset + ef_buf);
8- offset += 4;
9-
10-+ if (!G.filename_full) {
11-+ /* Check if we have a unicode extra section but no filename set */
12-+ return PK_ERR;
13-+ }
14-+
15- /*
16- * Compute 32-bit crc
17- */
18--
19- chksum = crc32(chksum, (uch *)(G.filename_full),
20- strlen(G.filename_full));
R repo/unzip/patches/unzip-zipbomb-manpage.patch =>
repo/unzip/patches/zipbomb-manpage.patch
+1,
-1
1@@ -16,7 +16,7 @@ index 21816d1..4d66073 100644
2 .IP 11
3 no matching files were found.
4 +.IP 12
5-+invalid zip file with overlapped components (possible zip bomb).
6++invalid zip file with overlapped components (possible zip-bomb). The zip-bomb checks can be disabled by using the UNZIP_DISABLE_ZIPBOMB_DETECTION=TRUE environment variable.
7 .IP 50
8 the disk is (or was) full during extraction.
9 .IP 51
R repo/unzip/patches/unzip-zipbomb-part1.patch =>
repo/unzip/patches/zipbomb-part1.patch
+0,
-0
R repo/unzip/patches/unzip-zipbomb-part2.patch =>
repo/unzip/patches/zipbomb-part2.patch
+0,
-0
R repo/unzip/patches/unzip-zipbomb-part3.patch =>
repo/unzip/patches/zipbomb-part3.patch
+0,
-0
+25,
-0
1@@ -0,0 +1,25 @@
2+From 5e2efcd633a4a1fb95a129a75508e7d769e767be Mon Sep 17 00:00:00 2001
3+From: Mark Adler <madler@alumni.caltech.edu>
4+Date: Sun, 9 Feb 2020 20:36:28 -0800
5+Subject: [PATCH] Fix bug in UZbunzip2() that incorrectly updated G.incnt.
6+
7+The update assumed a full buffer, which is not always full. This
8+could result in a false overlapped element detection when a small
9+bzip2-compressed file was unzipped. This commit remedies that.
10+---
11+ extract.c | 2 +-
12+ 1 file changed, 1 insertion(+), 1 deletion(-)
13+
14+diff --git a/extract.c b/extract.c
15+index d9866f9..0cb7bfc 100644
16+--- a/extract.c
17++++ b/extract.c
18+@@ -3010,7 +3010,7 @@ __GDEF
19+ #endif
20+
21+ G.inptr = (uch *)bstrm.next_in;
22+- G.incnt = (G.inbuf + INBUFSIZ) - G.inptr; /* reset for other routines */
23++ G.incnt -= G.inptr - G.inbuf; /* reset for other routines */
24+
25+ uzbunzip_cleanup_exit:
26+ err = BZ2_bzDecompressEnd(&bstrm);
+26,
-0
1@@ -0,0 +1,26 @@
2+From 5c572555cf5d80309a07c30cf7a54b2501493720 Mon Sep 17 00:00:00 2001
3+From: Mark Adler <madler@alumni.caltech.edu>
4+Date: Sun, 9 Feb 2020 21:39:09 -0800
5+Subject: [PATCH] Fix bug in UZinflate() that incorrectly updated G.incnt.
6+
7+The update assumed a full buffer, which is not always full. This
8+could result in a false overlapped element detection when a small
9+deflate-compressed file was unzipped using an old zlib. This
10+commit remedies that.
11+---
12+ inflate.c | 2 +-
13+ 1 file changed, 1 insertion(+), 1 deletion(-)
14+
15+diff --git a/inflate.c b/inflate.c
16+index 2f5a015..70e3cc0 100644
17+--- a/inflate.c
18++++ b/inflate.c
19+@@ -700,7 +700,7 @@ int UZinflate(__G__ is_defl64)
20+ G.dstrm.total_out));
21+
22+ G.inptr = (uch *)G.dstrm.next_in;
23+- G.incnt = (G.inbuf + INBUFSIZ) - G.inptr; /* reset for other routines */
24++ G.incnt -= G.inptr - G.inbuf; /* reset for other routines */
25+
26+ uzinflate_cleanup_exit:
27+ err = inflateReset(&G.dstrm);
+95,
-0
1@@ -0,0 +1,95 @@
2+From 122050bac16fae82a460ff739fb1ca0f106e9d85 Mon Sep 17 00:00:00 2001
3+From: Mark Adler <madler@alumni.caltech.edu>
4+Date: Sat, 2 Jan 2021 13:09:34 -0800
5+Subject: [PATCH] Determine Zip64 status entry-by-entry instead of for entire
6+ file.
7+
8+Fixes a bug for zip files with mixed Zip64 and not Zip64 entries,
9+which resulted in an incorrect data descriptor length. The bug is
10+seen when a Zip64 entry precedes a non-Zip64 entry, in which case
11+the data descriptor would have been assumed to be larger than it
12+is, resulting in an incorrect bomb warning due to a perceived
13+overlap with the next entry. This commit determines and saves the
14+Zip64 status for each entry based on the central directory, and
15+then computes the length of each data descriptor accordingly.
16+---
17+ extract.c | 5 +++--
18+ globals.h | 2 --
19+ process.c | 4 +---
20+ unzpriv.h | 1 +
21+ 4 files changed, 5 insertions(+), 7 deletions(-)
22+
23+diff --git a/extract.c b/extract.c
24+index 504afd6..878817d 100644
25+--- a/extract.c
26++++ b/extract.c
27+@@ -658,6 +658,7 @@ int extract_or_test_files(__G) /* return PK-type error code */
28+ break;
29+ }
30+ }
31++ G.pInfo->zip64 = FALSE;
32+ if ((error = do_string(__G__ G.crec.extra_field_length,
33+ EXTRA_FIELD)) != 0)
34+ {
35+@@ -2187,12 +2188,12 @@ static int extract_or_test_member(__G) /* return PK-type error code */
36+ (clen == SIG && /* if not SIG, no signature */
37+ ((G.lrec.csize & LOW) != SIG || /* if not SIG, have signature */
38+ (ulen == SIG && /* if not SIG, no signature */
39+- (G.zip64 ? G.lrec.csize >> 32 : G.lrec.ucsize) != SIG
40++ (G.pInfo->zip64 ? G.lrec.csize >> 32 : G.lrec.ucsize) != SIG
41+ /* if not SIG, have signature */
42+ )))))
43+ /* skip four more bytes to account for signature */
44+ shy += 4 - readbuf((char *)buf, 4);
45+- if (G.zip64)
46++ if (G.pInfo->zip64)
47+ shy += 8 - readbuf((char *)buf, 8); /* skip eight more for ZIP64 */
48+ if (shy)
49+ error = PK_ERR;
50+diff --git a/globals.h b/globals.h
51+index f9c6daf..a883c90 100644
52+--- a/globals.h
53++++ b/globals.h
54+@@ -261,8 +261,6 @@ typedef struct Globals {
55+ ecdir_rec ecrec; /* used in unzip.c, extract.c */
56+ z_stat statbuf; /* used by main, mapname, check_for_newer */
57+
58+- int zip64; /* true if Zip64 info in extra field */
59+-
60+ int mem_mode;
61+ uch *outbufptr; /* extract.c static */
62+ ulg outsize; /* extract.c static */
63+diff --git a/process.c b/process.c
64+index d75d405..d643c6f 100644
65+--- a/process.c
66++++ b/process.c
67+@@ -1903,8 +1903,6 @@ int getZip64Data(__G__ ef_buf, ef_len)
68+ #define Z64FLGS 0xffff
69+ #define Z64FLGL 0xffffffff
70+
71+- G.zip64 = FALSE;
72+-
73+ if (ef_len == 0 || ef_buf == NULL)
74+ return PK_COOL;
75+
76+@@ -1943,7 +1941,7 @@ int getZip64Data(__G__ ef_buf, ef_len)
77+ break; /* Expect only one EF_PKSZ64 block. */
78+ #endif /* 0 */
79+
80+- G.zip64 = TRUE;
81++ G.pInfo->zip64 = TRUE;
82+ }
83+
84+ /* Skip this extra field block. */
85+diff --git a/unzpriv.h b/unzpriv.h
86+index 09f288e..75b3359 100644
87+--- a/unzpriv.h
88++++ b/unzpriv.h
89+@@ -2034,6 +2034,7 @@ typedef struct min_info {
90+ #ifdef UNICODE_SUPPORT
91+ unsigned GPFIsUTF8: 1; /* crec gen_purpose_flag UTF-8 bit 11 is set */
92+ #endif
93++ unsigned zip64: 1; /* true if entry has Zip64 extra block */
94+ #ifndef SFX
95+ char Far *cfilname; /* central header version of filename */
96+ #endif
+215,
-0
1@@ -0,0 +1,215 @@
2+From 5b44c818b96193b3e240f38f61985fa2bc780eb7 Mon Sep 17 00:00:00 2001
3+From: Jakub Martisko <jamartis@redhat.com>
4+Date: Tue, 30 Nov 2021 15:42:17 +0100
5+Subject: [PATCH] Add an option to disable the zipbomb detection
6+
7+This can be done by settting a newly introduced environment variable
8+UNZIP_DISABLE_ZIPBOMB_DETECTION to {TRUE,True,true}. If the variable is unset, or
9+set to any other value the zipbomb detection is left enabled.
10+
11+Example:
12+ UNZIP_DISABLE_ZIPBOMB_DETECTION=True unzip ./zbsm.zip -d ./test
13+---
14+ extract.c | 85 ++++++++++++++++++++++++++++++-------------------------
15+ unzip.c | 15 ++++++++--
16+ unzip.h | 1 +
17+ 3 files changed, 60 insertions(+), 41 deletions(-)
18+
19+diff --git a/extract.c b/extract.c
20+index 878817d..3e58071 100644
21+--- a/extract.c
22++++ b/extract.c
23+@@ -322,7 +322,8 @@ static ZCONST char Far BadExtraFieldCRC[] =
24+ static ZCONST char Far NotEnoughMemCover[] =
25+ "error: not enough memory for bomb detection\n";
26+ static ZCONST char Far OverlappedComponents[] =
27+- "error: invalid zip file with overlapped components (possible zip bomb)\n";
28++ "error: invalid zip file with overlapped components (possible zip bomb)\n \
29++To unzip the file anyway, rerun the command with UNZIP_DISABLE_ZIPBOMB_DETECTION=TRUE environmnent variable\n";
30+
31+
32+
33+@@ -502,35 +503,37 @@ int extract_or_test_files(__G) /* return PK-type error code */
34+ the end of central directory record (including the Zip64 end of central
35+ directory locator, if present), and the Zip64 end of central directory
36+ record, if present. */
37+- if (G.cover == NULL) {
38++ if (uO.zipbomb == TRUE) {
39++ if (G.cover == NULL) {
40+ G.cover = malloc(sizeof(cover_t));
41+ if (G.cover == NULL) {
42+- Info(slide, 0x401, ((char *)slide,
43+- LoadFarString(NotEnoughMemCover)));
44+- return PK_MEM;
45++ Info(slide, 0x401, ((char *)slide,
46++ LoadFarString(NotEnoughMemCover)));
47++ return PK_MEM;
48+ }
49+ ((cover_t *)G.cover)->span = NULL;
50+ ((cover_t *)G.cover)->max = 0;
51+- }
52+- ((cover_t *)G.cover)->num = 0;
53+- if (cover_add((cover_t *)G.cover,
54+- G.extra_bytes + G.ecrec.offset_start_central_directory,
55+- G.extra_bytes + G.ecrec.offset_start_central_directory +
56+- G.ecrec.size_central_directory) != 0) {
57++ }
58++ ((cover_t *)G.cover)->num = 0;
59++ if (cover_add((cover_t *)G.cover,
60++ G.extra_bytes + G.ecrec.offset_start_central_directory,
61++ G.extra_bytes + G.ecrec.offset_start_central_directory +
62++ G.ecrec.size_central_directory) != 0) {
63+ Info(slide, 0x401, ((char *)slide,
64+- LoadFarString(NotEnoughMemCover)));
65++ LoadFarString(NotEnoughMemCover)));
66+ return PK_MEM;
67+- }
68+- if ((G.extra_bytes != 0 &&
69+- cover_add((cover_t *)G.cover, 0, G.extra_bytes) != 0) ||
70+- (G.ecrec.have_ecr64 &&
71+- cover_add((cover_t *)G.cover, G.ecrec.ec64_start,
72+- G.ecrec.ec64_end) != 0) ||
73+- cover_add((cover_t *)G.cover, G.ecrec.ec_start,
74+- G.ecrec.ec_end) != 0) {
75++ }
76++ if ((G.extra_bytes != 0 &&
77++ cover_add((cover_t *)G.cover, 0, G.extra_bytes) != 0) ||
78++ (G.ecrec.have_ecr64 &&
79++ cover_add((cover_t *)G.cover, G.ecrec.ec64_start,
80++ G.ecrec.ec64_end) != 0) ||
81++ cover_add((cover_t *)G.cover, G.ecrec.ec_start,
82++ G.ecrec.ec_end) != 0) {
83+ Info(slide, 0x401, ((char *)slide,
84+- LoadFarString(OverlappedComponents)));
85++ LoadFarString(OverlappedComponents)));
86+ return PK_BOMB;
87++ }
88+ }
89+
90+ /*---------------------------------------------------------------------------
91+@@ -1222,10 +1225,12 @@ static int extract_or_test_entrylist(__G__ numchunk,
92+
93+ /* seek_zipf(__G__ pInfo->offset); */
94+ request = G.pInfo->offset + G.extra_bytes;
95+- if (cover_within((cover_t *)G.cover, request)) {
96++ if (uO.zipbomb == TRUE) {
97++ if (cover_within((cover_t *)G.cover, request)) {
98+ Info(slide, 0x401, ((char *)slide,
99+- LoadFarString(OverlappedComponents)));
100++ LoadFarString(OverlappedComponents)));
101+ return PK_BOMB;
102++ }
103+ }
104+ inbuf_offset = request % INBUFSIZ;
105+ bufstart = request - inbuf_offset;
106+@@ -1758,17 +1763,19 @@ reprompt:
107+ return IZ_CTRLC; /* cancel operation by user request */
108+ }
109+ #endif
110+- error = cover_add((cover_t *)G.cover, request,
111+- G.cur_zipfile_bufstart + (G.inptr - G.inbuf));
112+- if (error < 0) {
113++ if (uO.zipbomb == TRUE) {
114++ error = cover_add((cover_t *)G.cover, request,
115++ G.cur_zipfile_bufstart + (G.inptr - G.inbuf));
116++ if (error < 0) {
117+ Info(slide, 0x401, ((char *)slide,
118+- LoadFarString(NotEnoughMemCover)));
119++ LoadFarString(NotEnoughMemCover)));
120+ return PK_MEM;
121+- }
122+- if (error != 0) {
123++ }
124++ if (error != 0) {
125+ Info(slide, 0x401, ((char *)slide,
126+- LoadFarString(OverlappedComponents)));
127++ LoadFarString(OverlappedComponents)));
128+ return PK_BOMB;
129++ }
130+ }
131+ #ifdef MACOS /* MacOS is no preemptive OS, thus call event-handling by hand */
132+ UserStop();
133+@@ -2171,8 +2178,8 @@ static int extract_or_test_member(__G) /* return PK-type error code */
134+ }
135+
136+ undefer_input(__G);
137+-
138+- if ((G.lrec.general_purpose_bit_flag & 8) != 0) {
139++ if (uO.zipbomb == TRUE) {
140++ if ((G.lrec.general_purpose_bit_flag & 8) != 0) {
141+ /* skip over data descriptor (harder than it sounds, due to signature
142+ * ambiguity)
143+ */
144+@@ -2189,16 +2196,16 @@ static int extract_or_test_member(__G) /* return PK-type error code */
145+ ((G.lrec.csize & LOW) != SIG || /* if not SIG, have signature */
146+ (ulen == SIG && /* if not SIG, no signature */
147+ (G.pInfo->zip64 ? G.lrec.csize >> 32 : G.lrec.ucsize) != SIG
148+- /* if not SIG, have signature */
149++ /* if not SIG, have signature */
150+ )))))
151+- /* skip four more bytes to account for signature */
152+- shy += 4 - readbuf((char *)buf, 4);
153++ /* skip four more bytes to account for signature */
154++ shy += 4 - readbuf((char *)buf, 4);
155+ if (G.pInfo->zip64)
156+- shy += 8 - readbuf((char *)buf, 8); /* skip eight more for ZIP64 */
157++ shy += 8 - readbuf((char *)buf, 8); /* skip eight more for ZIP64 */
158+ if (shy)
159+- error = PK_ERR;
160++ error = PK_ERR;
161++ }
162+ }
163+-
164+ return error;
165+
166+ } /* end function extract_or_test_member() */
167+diff --git a/unzip.c b/unzip.c
168+index 8dbfc95..abb3644 100644
169+--- a/unzip.c
170++++ b/unzip.c
171+@@ -1329,10 +1329,9 @@ int uz_opts(__G__ pargc, pargv)
172+ int *pargc;
173+ char ***pargv;
174+ {
175+- char **argv, *s;
176++ char **argv, *s, *zipbomb_envar;
177+ int argc, c, error=FALSE, negative=0, showhelp=0;
178+
179+-
180+ argc = *pargc;
181+ argv = *pargv;
182+
183+@@ -1923,6 +1922,18 @@ opts_done: /* yes, very ugly...but only used by UnZipSFX with -x xlist */
184+ else
185+ G.extract_flag = TRUE;
186+
187++ /* Disable the zipbomb detection, this is the only option set only via the shell variables but it should at least not clash with something in the future. */
188++ zipbomb_envar = getenv("UNZIP_DISABLE_ZIPBOMB_DETECTION");
189++ uO.zipbomb = TRUE;
190++ if (zipbomb_envar != NULL) {
191++ /* strcasecmp might be a better approach here but it is POSIX-only */
192++ if ((strcmp ("TRUE", zipbomb_envar) == 0)
193++ || (strcmp ("True", zipbomb_envar) == 0)
194++ || (strcmp ("true",zipbomb_envar) == 0)) {
195++ uO.zipbomb = FALSE;
196++ }
197++ }
198++
199+ *pargc = argc;
200+ *pargv = argv;
201+ return PK_OK;
202+diff --git a/unzip.h b/unzip.h
203+index ed24a5b..e7665e8 100644
204+--- a/unzip.h
205++++ b/unzip.h
206+@@ -559,6 +559,7 @@ typedef struct _UzpOpts {
207+ #ifdef UNIX
208+ int cflxflag; /* -^: allow control chars in extracted filenames */
209+ #endif
210++ int zipbomb;
211+ #endif /* !FUNZIP */
212+ } UzpOpts;
213+
214+--
215+2.33.0
216+
+24,
-27
1@@ -1,32 +1,29 @@
2 https://versaweb.dl.sourceforge.net/project/infozip/UnZip%206.x%20%28latest%29/UnZip%206.0/unzip60.tar.gz
3-patches/0001-Fix-CVE-2016-9844-rhbz-1404283.patch
4-patches/series
5-patches/unzip-6.0-COVSCAN-fix-unterminated-string.patch
6-patches/unzip-6.0-alt-iconv-utf8-print.patch
7-patches/unzip-6.0-alt-iconv-utf8.patch
8-patches/unzip-6.0-attribs-overflow.patch
9-patches/unzip-6.0-bzip2-configure.patch
10-patches/unzip-6.0-caseinsensitive.patch
11-patches/unzip-6.0-close.patch
12-patches/unzip-6.0-configure.patch
13-patches/unzip-6.0-cve-2014-8139.patch
14-patches/unzip-6.0-cve-2014-8140.patch
15-patches/unzip-6.0-cve-2014-8141.patch
16-patches/unzip-6.0-cve-2018-1000035-heap-based-overflow.patch
17-patches/unzip-6.0-cve-2018-18384.patch
18+patches/08-allow-greater-hostver-values.patch
19+patches/10-unzip-handle-pkware-verify.patch
20+patches/13-remove-build-date.patch
21+patches/20-unzip-uidgid-fix.patch
22+patches/21-fix-warning-messages-on-big-files.patch
23+patches/CVE-2014-8139.patch
24+patches/CVE-2014-8140.patch
25+patches/CVE-2014-8141.patch
26+patches/CVE-2014-9636.patch
27+patches/CVE-2014-9913.patch
28+patches/CVE-2016-9844.patch
29+patches/CVE-2018-1000035.patch
30+patches/CVE-2018-18384.patch
31+patches/CVE-2021-4217.patch
32+patches/CVE-2022-0529-and-CVE-2022-0530.patch
33+patches/large-symlinks.patch
34 patches/unzip-6.0-exec-shield.patch
35-patches/unzip-6.0-fix-recmatch.patch
36 patches/unzip-6.0-format-secure.patch
37 patches/unzip-6.0-heap-overflow-infloop.patch
38-patches/unzip-6.0-manpage-fix.patch
39-patches/unzip-6.0-overflow-long-fsize.patch
40-patches/unzip-6.0-overflow.patch
41-patches/unzip-6.0-symlink.patch
42 patches/unzip-6.0-timestamp.patch
43-patches/unzip-6.0-valgrind.patch
44-patches/unzip-6.0-x-option.patch
45-patches/unzip-6.0_CVE-2021-4217.patch
46-patches/unzip-zipbomb-manpage.patch
47-patches/unzip-zipbomb-part1.patch
48-patches/unzip-zipbomb-part2.patch
49-patches/unzip-zipbomb-part3.patch
50+patches/zipbomb-manpage.patch
51+patches/zipbomb-part1.patch
52+patches/zipbomb-part2.patch
53+patches/zipbomb-part3.patch
54+patches/zipbomb-part4.patch
55+patches/zipbomb-part5.patch
56+patches/zipbomb-part6.patch
57+patches/zipbomb-switch.patch