commit ac43795
hovercats
·
2024-04-30 01:03:01 +0000 UTC
parent a595789
unzip: import from oasis
33 files changed,
+1696,
-2
+3,
-2
1@@ -7,8 +7,8 @@ subgen 'byacc'
2 subgen 'bzip2'
3 subgen 'cacert'
4 subgen 'catgirl'
5-subgen 'curl'
6 subgen 'cproc'
7+subgen 'curl'
8 subgen 'dosfstools'
9 subgen 'e2fsprogs'
10 subgen 'elftoolchain'
11@@ -16,8 +16,8 @@ subgen 'file'
12 subgen 'flex'
13 subgen 'fspec-sync'
14 subgen 'git'
15-subgen 'kiss'
16 subgen 'iproute2'
17+subgen 'kiss'
18 subgen 'less'
19 subgen 'libcbor'
20 subgen 'libevent'
21@@ -52,6 +52,7 @@ subgen 'tinyalsa'
22 subgen 'transmission'
23 subgen 'tz'
24 subgen 'ubase'
25+subgen 'unzip'
26 subgen 'util-linux'
27 subgen 'vis'
28 subgen 'wpa_supplicant'
+2,
-0
1@@ -0,0 +1,2 @@
2+/src
3+/unzip60.tar.gz
+15,
-0
1@@ -0,0 +1,15 @@
2+#define ACORN_FTYPE_NFS
3+#define DATE_FORMAT DF_YMD
4+#define IZ_HAVE_UXUIDGID
5+#define LARGE_FILE_SUPPORT
6+#define UNICODE_SUPPORT
7+#define UNICODE_WCHAR
8+#define UNIX
9+#define USE_BZIP2
10+#define UTF8_MAYBE_NATIVE
11+#define WILD_STOP_AT_DIR
12+
13+/* why does Debian define these? */
14+#define NOMEMCPY
15+#define NO_LCHMOD
16+#define NO_WORKING_ISPRINT
+19,
-0
1@@ -0,0 +1,19 @@
2+cflags{
3+ '-include $dir/config.h',
4+ '-I $srcdir',
5+ '-isystem $builddir/pkg/bzip2/include',
6+}
7+
8+pkg.deps = {'pkg/bzip2/headers'}
9+
10+exe('unzip', [[
11+ unzip.c crc32.c crypt.c envargs.c explode.c
12+ extract.c fileio.c globals.c inflate.c list.c match.c
13+ process.c ttyio.c ubz2err.c unreduce.c unshrink.c zipinfo.c
14+ unix/unix.c
15+ $builddir/pkg/bzip2/libbz2.a
16+]])
17+file('bin/unzip', '755', '$outdir/unzip')
18+man{'man/unzip.1'}
19+
20+fetch 'curl'
1@@ -0,0 +1,317 @@
2+From 85238f823da4858625f482c696f48e460ba27625 Mon Sep 17 00:00:00 2001
3+From: Santiago Vila <sanvila@debian.org>
4+Date: Sat, 15 Jun 2019 18:13:11 -0700
5+Subject: [PATCH] In Debian, manpages are in section 1, not in section 1L
6+
7+---
8+ man/funzip.1 | 8 ++++----
9+ man/unzip.1 | 24 ++++++++++++------------
10+ man/unzipsfx.1 | 32 ++++++++++++++++----------------
11+ man/zipgrep.1 | 8 ++++----
12+ man/zipinfo.1 | 10 +++++-----
13+ 5 files changed, 41 insertions(+), 41 deletions(-)
14+
15+diff --git a/man/funzip.1 b/man/funzip.1
16+index 30206e4..a9b4195 100644
17+--- a/man/funzip.1
18++++ b/man/funzip.1
19+@@ -20,7 +20,7 @@
20+ .in -4n
21+ ..
22+ .\" =========================================================================
23+-.TH FUNZIP 1L "20 April 2009 (v3.95)" "Info-ZIP"
24++.TH FUNZIP 1 "20 April 2009 (v3.95)" "Info-ZIP"
25+ .SH NAME
26+ funzip \- filter for extracting from a ZIP archive in a pipe
27+ .PD
28+@@ -78,7 +78,7 @@ funzip test.zip > /dev/null
29+ .EE
30+ .PP
31+ To use \fIzip\fP and \fIfunzip\fP in place of \fIcompress\fP(1) and
32+-\fIzcat\fP(1) (or \fIgzip\fP(1L) and \fIgzcat\fP(1L)) for tape backups:
33++\fIzcat\fP(1) (or \fIgzip\fP(1) and \fIgzcat\fP(1)) for tape backups:
34+ .PP
35+ .EX
36+ tar cf \- . | zip \-7 | dd of=/dev/nrst0 obs=8k
37+@@ -108,8 +108,8 @@ itself (future release).
38+ .PD
39+ .\" =========================================================================
40+ .SH "SEE ALSO"
41+-\fIgzip\fP(1L), \fIunzip\fP(1L), \fIunzipsfx\fP(1L), \fIzip\fP(1L),
42+-\fIzipcloak\fP(1L), \fIzipinfo\fP(1L), \fIzipnote\fP(1L), \fIzipsplit\fP(1L)
43++\fIgzip\fP(1), \fIunzip\fP(1), \fIunzipsfx\fP(1), \fIzip\fP(1),
44++\fIzipcloak\fP(1), \fIzipinfo\fP(1), \fIzipnote\fP(1), \fIzipsplit\fP(1)
45+ .PD
46+ .\" =========================================================================
47+ .SH URL
48+diff --git a/man/unzip.1 b/man/unzip.1
49+index 75a7060..eee43a9 100644
50+--- a/man/unzip.1
51++++ b/man/unzip.1
52+@@ -20,7 +20,7 @@
53+ .in -4n
54+ ..
55+ .\" =========================================================================
56+-.TH UNZIP 1L "20 April 2009 (v6.0)" "Info-ZIP"
57++.TH UNZIP 1 "20 April 2009 (v6.0)" "Info-ZIP"
58+ .SH NAME
59+ unzip \- list, test and extract compressed files in a ZIP archive
60+ .PD
61+@@ -34,7 +34,7 @@ unzip \- list, test and extract compressed files in a ZIP archive
62+ \fIunzip\fP will list, test, or extract files from a ZIP archive, commonly
63+ found on MS-DOS systems. The default behavior (with no options) is to extract
64+ into the current directory (and subdirectories below it) all files from the
65+-specified ZIP archive. A companion program, \fIzip\fP(1L), creates ZIP
66++specified ZIP archive. A companion program, \fIzip\fP(1), creates ZIP
67+ archives; both programs are compatible with archives created by PKWARE's
68+ \fIPKZIP\fP and \fIPKUNZIP\fP for MS-DOS, but in many cases the program
69+ options or default behaviors differ.
70+@@ -105,8 +105,8 @@ only a reminder of the basic \fIunzip\fP syntax rather than an exhaustive
71+ list of all possible flags. The exhaustive list follows:
72+ .TP
73+ .B \-Z
74+-\fIzipinfo\fP(1L) mode. If the first option on the command line is \fB\-Z\fP,
75+-the remaining options are taken to be \fIzipinfo\fP(1L) options. See the
76++\fIzipinfo\fP(1) mode. If the first option on the command line is \fB\-Z\fP,
77++the remaining options are taken to be \fIzipinfo\fP(1) options. See the
78+ appropriate manual page for a description of these options.
79+ .TP
80+ .B \-A
81+@@ -178,7 +178,7 @@ encrypted entries from the compressed size numbers. Therefore,
82+ compressed size and compression ratio figures are independent of the entry's
83+ encryption status and show the correct compression performance. (The complete
84+ size of the encrypted compressed data stream for zipfile entries is reported
85+-by the more verbose \fIzipinfo\fP(1L) reports, see the separate manual.)
86++by the more verbose \fIzipinfo\fP(1) reports, see the separate manual.)
87+ When no zipfile is specified (that is, the complete command is simply
88+ ``\fCunzip \-v\fR''), a diagnostic screen is printed. In addition to
89+ the normal header with release date and version, \fIunzip\fP lists the
90+@@ -379,8 +379,8 @@ file, skip extraction of all existing files, or rename the current file.
91+ .TP
92+ .B \-N
93+ [Amiga] extract file comments as Amiga filenotes. File comments are created
94+-with the \-c option of \fIzip\fP(1L), or with the \-N option of the Amiga port
95+-of \fIzip\fP(1L), which stores filenotes as comments.
96++with the \-c option of \fIzip\fP(1), or with the \-N option of the Amiga port
97++of \fIzip\fP(1), which stores filenotes as comments.
98+ .TP
99+ .B \-o
100+ overwrite existing files without prompting. This is a dangerous option, so
101+@@ -598,7 +598,7 @@ Unix \fInice\fP(1).
102+ As suggested by the examples above, the default variable names are UNZIP_OPTS
103+ for VMS (where the symbol used to install \fIunzip\fP as a foreign command
104+ would otherwise be confused with the environment variable), and UNZIP
105+-for all other operating systems. For compatibility with \fIzip\fP(1L),
106++for all other operating systems. For compatibility with \fIzip\fP(1),
107+ UNZIPOPT is also accepted (don't ask). If both UNZIP and UNZIPOPT
108+ are defined, however, UNZIP takes precedence. \fIunzip\fP's diagnostic
109+ option (\fB\-v\fP with no zipfile name) can be used to check the values
110+@@ -648,8 +648,8 @@ prompt for another password, and so on until all files are extracted. If
111+ a password is not known, entering a null password (that is, just a carriage
112+ return or ``Enter'') is taken as a signal to skip all further prompting.
113+ Only unencrypted files in the archive(s) will thereafter be extracted. (In
114+-fact, that's not quite true; older versions of \fIzip\fP(1L) and
115+-\fIzipcloak\fP(1L) allowed null passwords, so \fIunzip\fP checks each encrypted
116++fact, that's not quite true; older versions of \fIzip\fP(1) and
117++\fIzipcloak\fP(1) allowed null passwords, so \fIunzip\fP checks each encrypted
118+ file to see if the null password works. This may result in ``false positives''
119+ and extraction errors, as noted above.)
120+ .PP
121+@@ -943,8 +943,8 @@ deleted.
122+ .PD
123+ .\" =========================================================================
124+ .SH "SEE ALSO"
125+-\fIfunzip\fP(1L), \fIzip\fP(1L), \fIzipcloak\fP(1L), \fIzipgrep\fP(1L),
126+-\fIzipinfo\fP(1L), \fIzipnote\fP(1L), \fIzipsplit\fP(1L)
127++\fIfunzip\fP(1), \fIzip\fP(1), \fIzipcloak\fP(1), \fIzipgrep\fP(1),
128++\fIzipinfo\fP(1), \fIzipnote\fP(1), \fIzipsplit\fP(1)
129+ .PD
130+ .\" =========================================================================
131+ .SH URL
132+diff --git a/man/unzipsfx.1 b/man/unzipsfx.1
133+index d9a0e59..533711f 100644
134+--- a/man/unzipsfx.1
135++++ b/man/unzipsfx.1
136+@@ -20,7 +20,7 @@
137+ .in -4n
138+ ..
139+ .\" =========================================================================
140+-.TH UNZIPSFX 1L "20 April 2009 (v6.0)" "Info-ZIP"
141++.TH UNZIPSFX 1 "20 April 2009 (v6.0)" "Info-ZIP"
142+ .SH NAME
143+ unzipsfx \- self-extracting stub for prepending to ZIP archives
144+ .PD
145+@@ -30,7 +30,7 @@ unzipsfx \- self-extracting stub for prepending to ZIP archives
146+ .PD
147+ .\" =========================================================================
148+ .SH DESCRIPTION
149+-\fIunzipsfx\fP is a modified version of \fIunzip\fP(1L) designed to be
150++\fIunzipsfx\fP is a modified version of \fIunzip\fP(1) designed to be
151+ prepended to existing ZIP archives in order to form self-extracting archives.
152+ Instead of taking its first non-flag argument to be the zipfile(s) to be
153+ extracted, \fIunzipsfx\fP seeks itself under the name by which it was invoked
154+@@ -109,7 +109,7 @@ literal subdirectory ``\fB~\fP'' of the current directory.
155+ .PD
156+ .\" =========================================================================
157+ .SH OPTIONS
158+-\fIunzipsfx\fP supports the following \fIunzip\fP(1L) options: \fB\-c\fP
159++\fIunzipsfx\fP supports the following \fIunzip\fP(1) options: \fB\-c\fP
160+ and \fB\-p\fP (extract to standard output/screen), \fB\-f\fP and \fB\-u\fP
161+ (freshen and update existing files upon extraction), \fB\-t\fP (test
162+ archive) and \fB\-z\fP (print archive comment). All normal listing options
163+@@ -118,11 +118,11 @@ option (\fB\-t\fP) may be used as a ``poor man's'' listing. Alternatively,
164+ those creating self-extracting archives may wish to include a short listing
165+ in the zipfile comment.
166+ .PP
167+-See \fIunzip\fP(1L) for a more complete description of these options.
168++See \fIunzip\fP(1) for a more complete description of these options.
169+ .PD
170+ .\" =========================================================================
171+ .SH MODIFIERS
172+-\fIunzipsfx\fP currently supports all \fIunzip\fP(1L) modifiers: \fB\-a\fP
173++\fIunzipsfx\fP currently supports all \fIunzip\fP(1) modifiers: \fB\-a\fP
174+ (convert text files), \fB\-n\fP (never overwrite), \fB\-o\fP (overwrite
175+ without prompting), \fB\-q\fP (operate quietly), \fB\-C\fP (match names
176+ case-insensitively), \fB\-L\fP (convert uppercase-OS names to lowercase),
177+@@ -137,18 +137,18 @@ files have the appropriate format for the local OS. EBCDIC conversion will
178+ of course continue to be supported since the zipfile format implies ASCII
179+ storage of text files.)
180+ .PP
181+-See \fIunzip\fP(1L) for a more complete description of these modifiers.
182++See \fIunzip\fP(1) for a more complete description of these modifiers.
183+ .PD
184+ .\" =========================================================================
185+ .SH "ENVIRONMENT OPTIONS"
186+-\fIunzipsfx\fP uses the same environment variables as \fIunzip\fP(1L) does,
187++\fIunzipsfx\fP uses the same environment variables as \fIunzip\fP(1) does,
188+ although this is likely to be an issue only for the person creating and
189+-testing the self-extracting archive. See \fIunzip\fP(1L) for details.
190++testing the self-extracting archive. See \fIunzip\fP(1) for details.
191+ .PD
192+ .\" =========================================================================
193+ .SH DECRYPTION
194+-Decryption is supported exactly as in \fIunzip\fP(1L); that is, interactively
195+-with a non-echoing prompt for the password(s). See \fIunzip\fP(1L) for
196++Decryption is supported exactly as in \fIunzip\fP(1); that is, interactively
197++with a non-echoing prompt for the password(s). See \fIunzip\fP(1) for
198+ details. Once again, note that if the archive has no encrypted files there
199+ is no reason to use a version of \fIunzipsfx\fP with decryption support;
200+ that only adds to the size of the archive.
201+@@ -286,7 +286,7 @@ available that provide the full path name, so the archive may be invoked
202+ from anywhere in the user's path. The situation is not known for AmigaDOS,
203+ Atari TOS, MacOS, etc.
204+ .PP
205+-As noted above, a number of the normal \fIunzip\fP(1L) functions have
206++As noted above, a number of the normal \fIunzip\fP(1) functions have
207+ been removed in order to make \fIunzipsfx\fP smaller: usage and diagnostic
208+ info, listing functions and extraction to other directories. Also, only
209+ stored and deflated files are supported. The latter limitation is mainly
210+@@ -303,17 +303,17 @@ does not work. (For technically oriented users, the attached archive is
211+ defined as a ``debug hunk.'') There may be compatibility problems between
212+ the ROM levels of older Amigas and newer ones.
213+ .PP
214+-All current bugs in \fIunzip\fP(1L) exist in \fIunzipsfx\fP as well.
215++All current bugs in \fIunzip\fP(1) exist in \fIunzipsfx\fP as well.
216+ .PD
217+ .\" =========================================================================
218+ .SH DIAGNOSTICS
219+ \fIunzipsfx\fP's exit status (error level) is identical to that of
220+-\fIunzip\fP(1L); see the corresponding man page.
221++\fIunzip\fP(1); see the corresponding man page.
222+ .PD
223+ .\" =========================================================================
224+ .SH "SEE ALSO"
225+-\fIfunzip\fP(1L), \fIunzip\fP(1L), \fIzip\fP(1L), \fIzipcloak\fP(1L),
226+-\fIzipgrep\fP(1L), \fIzipinfo\fP(1L), \fIzipnote\fP(1L), \fIzipsplit\fP(1L)
227++\fIfunzip\fP(1), \fIunzip\fP(1), \fIzip\fP(1), \fIzipcloak\fP(1),
228++\fIzipgrep\fP(1), \fIzipinfo\fP(1), \fIzipnote\fP(1), \fIzipsplit\fP(1)
229+ .PD
230+ .PD
231+ .\" =========================================================================
232+@@ -330,7 +330,7 @@ or
233+ .\" =========================================================================
234+ .SH AUTHORS
235+ Greg Roelofs was responsible for the basic modifications to UnZip necessary
236+-to create UnZipSFX. See \fIunzip\fP(1L) for the current list of Zip-Bugs
237++to create UnZipSFX. See \fIunzip\fP(1) for the current list of Zip-Bugs
238+ authors, or the file CONTRIBS in the UnZip source distribution for the
239+ full list of Info-ZIP contributors.
240+ .PD
241+diff --git a/man/zipgrep.1 b/man/zipgrep.1
242+index dad83f8..252fcae 100644
243+--- a/man/zipgrep.1
244++++ b/man/zipgrep.1
245+@@ -8,7 +8,7 @@
246+ .\" zipgrep.1 by Greg Roelofs.
247+ .\"
248+ .\" =========================================================================
249+-.TH ZIPGREP 1L "20 April 2009" "Info-ZIP"
250++.TH ZIPGREP 1 "20 April 2009" "Info-ZIP"
251+ .SH NAME
252+ zipgrep \- search files in a ZIP archive for lines matching a pattern
253+ .PD
254+@@ -21,7 +21,7 @@ zipgrep \- search files in a ZIP archive for lines matching a pattern
255+ .SH DESCRIPTION
256+ \fIzipgrep\fP will search files within a ZIP archive for lines matching
257+ the given string or pattern. \fIzipgrep\fP is a shell script and requires
258+-\fIegrep\fP(1) and \fIunzip\fP(1L) to function. Its output is identical to
259++\fIegrep\fP(1) and \fIunzip\fP(1) to function. Its output is identical to
260+ that of \fIegrep\fP(1).
261+ .PD
262+ .\" =========================================================================
263+@@ -69,8 +69,8 @@ All options prior to the ZIP archive filename are passed to \fIegrep\fP(1).
264+ .PD
265+ .\" =========================================================================
266+ .SH "SEE ALSO"
267+-\fIegrep\fP(1), \fIunzip\fP(1L), \fIzip\fP(1L), \fIfunzip\fP(1L),
268+-\fIzipcloak\fP(1L), \fIzipinfo\fP(1L), \fIzipnote\fP(1L), \fIzipsplit\fP(1L)
269++\fIegrep\fP(1), \fIunzip\fP(1), \fIzip\fP(1), \fIfunzip\fP(1),
270++\fIzipcloak\fP(1), \fIzipinfo\fP(1), \fIzipnote\fP(1), \fIzipsplit\fP(1)
271+ .PD
272+ .\" =========================================================================
273+ .SH URL
274+diff --git a/man/zipinfo.1 b/man/zipinfo.1
275+index 428e4b9..22d1fa2 100644
276+--- a/man/zipinfo.1
277++++ b/man/zipinfo.1
278+@@ -34,7 +34,7 @@
279+ .in -4n
280+ ..
281+ .\" =========================================================================
282+-.TH ZIPINFO 1L "20 April 2009 (v3.0)" "Info-ZIP"
283++.TH ZIPINFO 1 "20 April 2009 (v3.0)" "Info-ZIP"
284+ .SH NAME
285+ zipinfo \- list detailed information about a ZIP archive
286+ .PD
287+@@ -272,7 +272,7 @@ format:
288+ Note that because of limitations in the MS-DOS format used to store file
289+ times, the seconds field is always rounded to the nearest even second.
290+ For Unix files this is expected to change in the next major releases of
291+-\fIzip\fP(1L) and \fIunzip\fP.
292++\fIzip\fP(1) and \fIunzip\fP.
293+ .PP
294+ In addition to individual file information, a default zipfile listing
295+ also includes header and trailer lines:
296+@@ -361,7 +361,7 @@ of the Unix command \fInice\fP(1).
297+ As suggested above, the default variable names are ZIPINFO_OPTS for VMS
298+ (where the symbol used to install \fIzipinfo\fP as a foreign command
299+ would otherwise be confused with the environment variable), and ZIPINFO
300+-for all other operating systems. For compatibility with \fIzip\fP(1L),
301++for all other operating systems. For compatibility with \fIzip\fP(1),
302+ ZIPINFOOPT is also accepted (don't ask). If both ZIPINFO and ZIPINFOOPT
303+ are defined, however, ZIPINFO takes precedence. \fIunzip\fP's diagnostic
304+ option (\fB\-v\fP with no zipfile name) can be used to check the values
305+@@ -496,8 +496,8 @@ be simplified. (This is not to say that it will be.)
306+ .PP
307+ .\" =========================================================================
308+ .SH "SEE ALSO"
309+-\fIls\fP(1), \fIfunzip\fP(1L), \fIunzip\fP(1L), \fIunzipsfx\fP(1L),
310+-\fIzip\fP(1L), \fIzipcloak\fP(1L), \fIzipnote\fP(1L), \fIzipsplit\fP(1L)
311++\fIls\fP(1), \fIfunzip\fP(1), \fIunzip\fP(1), \fIunzipsfx\fP(1),
312++\fIzip\fP(1), \fIzipcloak\fP(1), \fIzipnote\fP(1), \fIzipsplit\fP(1)
313+ .PD
314+ .\" =========================================================================
315+ .SH URL
316+--
317+2.20.1
318+
1@@ -0,0 +1,26 @@
2+From 2561e7b7057dcca65b1ff2d5d2e12b4a1ba254fe Mon Sep 17 00:00:00 2001
3+From: Santiago Vila <sanvila@debian.org>
4+Date: Sat, 15 Jun 2019 18:13:11 -0700
5+Subject: [PATCH] "Branding patch": UnZip by Debian. Original by Info-ZIP.
6+
7+---
8+ unzip.c | 3 +--
9+ 1 file changed, 1 insertion(+), 2 deletions(-)
10+
11+diff --git a/unzip.c b/unzip.c
12+index 8dbfc95..1abaccb 100644
13+--- a/unzip.c
14++++ b/unzip.c
15+@@ -570,8 +570,7 @@ Send bug reports using //www.info-zip.org/zip-bug.html; see README for details.\
16+ #else /* !VMS */
17+ # ifdef COPYRIGHT_CLEAN
18+ static ZCONST char Far UnzipUsageLine1[] = "\
19+-UnZip %d.%d%d%s of %s, by Info-ZIP. Maintained by C. Spieler. Send\n\
20+-bug reports using http://www.info-zip.org/zip-bug.html; see README for details.\
21++UnZip %d.%d%d%s of %s, by Debian. Original by Info-ZIP.\
22+ \n\n";
23+ # else
24+ static ZCONST char Far UnzipUsageLine1[] = "\
25+--
26+2.20.1
27+
1@@ -0,0 +1,24 @@
2+From d27f3482cf46603d05d46bbc290ce6bb0f7ff210 Mon Sep 17 00:00:00 2001
3+From: Aurelien Jarno <aurel32@debian.org>
4+Date: Sat, 15 Jun 2019 18:13:11 -0700
5+Subject: [PATCH] #include <unistd.h> for kFreeBSD
6+
7+---
8+ unix/unxcfg.h | 1 +
9+ 1 file changed, 1 insertion(+)
10+
11+diff --git a/unix/unxcfg.h b/unix/unxcfg.h
12+index e39b283..c98c3b9 100644
13+--- a/unix/unxcfg.h
14++++ b/unix/unxcfg.h
15+@@ -52,6 +52,7 @@
16+
17+ #include <sys/types.h> /* off_t, time_t, dev_t, ... */
18+ #include <sys/stat.h>
19++#include <unistd.h>
20+
21+ #ifdef NO_OFF_T
22+ typedef long zoff_t;
23+--
24+2.20.1
25+
1@@ -0,0 +1,30 @@
2+From af50c278c5b2c57a76771825a80ca3ff9d315acd Mon Sep 17 00:00:00 2001
3+From: "Steven M. Schweda" <sms@antinode.info>
4+Date: Sat, 15 Jun 2019 18:13:11 -0700
5+Subject: [PATCH] Handle the PKWare verification bit of internal attributes
6+
7+---
8+ process.c | 7 +++++++
9+ 1 file changed, 7 insertions(+)
10+
11+diff --git a/process.c b/process.c
12+index 1e9a1e1..ed314e1 100644
13+--- a/process.c
14++++ b/process.c
15+@@ -1729,6 +1729,13 @@ int process_cdir_file_hdr(__G) /* return PK-type error code */
16+ else if (uO.L_flag > 1) /* let -LL force lower case for all names */
17+ G.pInfo->lcflag = 1;
18+
19++ /* Handle the PKWare verification bit, bit 2 (0x0004) of internal
20++ attributes. If this is set, then a verification checksum is in the
21++ first 3 bytes of the external attributes. In this case all we can use
22++ for setting file attributes is the last external attributes byte. */
23++ if (G.crec.internal_file_attributes & 0x0004)
24++ G.crec.external_file_attributes &= (ulg)0xff;
25++
26+ /* do Amigas (AMIGA_) also have volume labels? */
27+ if (IS_VOLID(G.crec.external_file_attributes) &&
28+ (G.pInfo->hostnum == FS_FAT_ || G.pInfo->hostnum == FS_HPFS_ ||
29+--
30+2.20.1
31+
1@@ -0,0 +1,38 @@
2+From 8e82b2116b190c9dd4ef2b56e1282ca2c6e30b62 Mon Sep 17 00:00:00 2001
3+From: "Steven M. Schweda" <sms@antinode.info>
4+Date: Sat, 15 Jun 2019 18:13:11 -0700
5+Subject: [PATCH] Restore uid and gid information when requested
6+
7+---
8+ process.c | 6 +++---
9+ 1 file changed, 3 insertions(+), 3 deletions(-)
10+
11+diff --git a/process.c b/process.c
12+index ed314e1..df58d28 100644
13+--- a/process.c
14++++ b/process.c
15+@@ -2904,7 +2904,7 @@ unsigned ef_scan_for_izux(ef_buf, ef_len, ef_is_c, dos_mdatetime,
16+ #ifdef IZ_HAVE_UXUIDGID
17+ if (eb_len >= EB_UX3_MINLEN
18+ && z_uidgid != NULL
19+- && (*((EB_HEADSIZE + 0) + ef_buf) == 1)
20++ && (*((EB_HEADSIZE + 0) + ef_buf) == 1))
21+ /* only know about version 1 */
22+ {
23+ uch uid_size;
24+@@ -2916,10 +2916,10 @@ unsigned ef_scan_for_izux(ef_buf, ef_len, ef_is_c, dos_mdatetime,
25+ flags &= ~0x0ff; /* ignore any previous UNIX field */
26+
27+ if ( read_ux3_value((EB_HEADSIZE + 2) + ef_buf,
28+- uid_size, z_uidgid[0])
29++ uid_size, &z_uidgid[0])
30+ &&
31+ read_ux3_value((EB_HEADSIZE + uid_size + 3) + ef_buf,
32+- gid_size, z_uidgid[1]) )
33++ gid_size, &z_uidgid[1]) )
34+ {
35+ flags |= EB_UX2_VALID; /* signal success */
36+ }
37+--
38+2.20.1
39+
1@@ -0,0 +1,29 @@
2+From d160eb934654c2a52ef7f8273a7f651fd6178b7d Mon Sep 17 00:00:00 2001
3+From: Andreas Schwab <schwab@linux-m68k.org>
4+Date: Sat, 15 Jun 2019 18:13:11 -0700
5+Subject: [PATCH] Initialize the symlink flag
6+
7+---
8+ process.c | 6 ++++++
9+ 1 file changed, 6 insertions(+)
10+
11+diff --git a/process.c b/process.c
12+index df58d28..3228bde 100644
13+--- a/process.c
14++++ b/process.c
15+@@ -1758,6 +1758,12 @@ int process_cdir_file_hdr(__G) /* return PK-type error code */
16+ = (G.crec.general_purpose_bit_flag & (1 << 11)) == (1 << 11);
17+ #endif
18+
19++#ifdef SYMLINKS
20++ /* Initialize the symlink flag, may be set by the platform-specific
21++ mapattr function. */
22++ G.pInfo->symlink = 0;
23++#endif
24++
25+ return PK_COOL;
26+
27+ } /* end function process_cdir_file_hdr() */
28+--
29+2.20.1
30+
1@@ -0,0 +1,25 @@
2+From 5ba63850818457aa3147ab40adc376ff7dc0f1c9 Mon Sep 17 00:00:00 2001
3+From: "Steven M. Schweda" <sms@antinode.info>
4+Date: Sat, 15 Jun 2019 18:13:11 -0700
5+Subject: [PATCH] Increase size of cfactorstr array to avoid buffer overflow
6+
7+---
8+ list.c | 2 +-
9+ 1 file changed, 1 insertion(+), 1 deletion(-)
10+
11+diff --git a/list.c b/list.c
12+index 15e0011..5de41e5 100644
13+--- a/list.c
14++++ b/list.c
15+@@ -97,7 +97,7 @@ int list_files(__G) /* return PK-type error code */
16+ {
17+ int do_this_file=FALSE, cfactor, error, error_in_archive=PK_COOL;
18+ #ifndef WINDLL
19+- char sgn, cfactorstr[10];
20++ char sgn, cfactorstr[12];
21+ int longhdr=(uO.vflag>1);
22+ #endif
23+ int date_format;
24+--
25+2.20.1
26+
1@@ -0,0 +1,25 @@
2+From 4d3698e4c587e5071ebedaa12daa8e86e2fcffc2 Mon Sep 17 00:00:00 2001
3+From: Santiago Vila <sanvila@debian.org>
4+Date: Sat, 15 Jun 2019 18:13:11 -0700
5+Subject: [PATCH] zipinfo.c: Do not crash when hostver byte is >= 100
6+
7+---
8+ zipinfo.c | 2 +-
9+ 1 file changed, 1 insertion(+), 1 deletion(-)
10+
11+diff --git a/zipinfo.c b/zipinfo.c
12+index a92bca9..5e77018 100644
13+--- a/zipinfo.c
14++++ b/zipinfo.c
15+@@ -2114,7 +2114,7 @@ static int zi_short(__G) /* return PK-type error code */
16+ else
17+ attribs[9] = (xattr & UNX_ISVTX)? 'T' : '-'; /* T==undefined */
18+
19+- sprintf(&attribs[12], "%u.%u", hostver/10, hostver%10);
20++ sprintf(&attribs[11], "%2u.%u", hostver/10, hostver%10);
21+ break;
22+
23+ } /* end switch (hostnum: external attributes format) */
24+--
25+2.20.1
26+
1@@ -0,0 +1,63 @@
2+From 9decdbe830f233fad7428df99e0c2d34887ac3cf Mon Sep 17 00:00:00 2001
3+From: "Steven M. Schweda" <sms@antinode.info>
4+Date: Sat, 15 Jun 2019 18:13:11 -0700
5+Subject: [PATCH] Fix CVE-2014-8139: CRC32 verification heap-based overflow
6+
7+---
8+ extract.c | 17 ++++++++++++++---
9+ 1 file changed, 14 insertions(+), 3 deletions(-)
10+
11+diff --git a/extract.c b/extract.c
12+index 1acd769..df0fa1c 100644
13+--- a/extract.c
14++++ b/extract.c
15+@@ -1,5 +1,5 @@
16+ /*
17+- Copyright (c) 1990-2009 Info-ZIP. All rights reserved.
18++ Copyright (c) 1990-2014 Info-ZIP. All rights reserved.
19+
20+ See the accompanying file LICENSE, version 2009-Jan-02 or later
21+ (the contents of which are also included in unzip.h) for terms of use.
22+@@ -298,6 +298,8 @@ char ZCONST Far TruncNTSD[] =
23+ #ifndef SFX
24+ static ZCONST char Far InconsistEFlength[] = "bad extra-field entry:\n \
25+ EF block length (%u bytes) exceeds remaining EF data (%u bytes)\n";
26++ static ZCONST char Far TooSmallEBlength[] = "bad extra-field entry:\n \
27++ EF block length (%u bytes) invalid (< %d)\n";
28+ static ZCONST char Far InvalidComprDataEAs[] =
29+ " invalid compressed data for EAs\n";
30+ # if (defined(WIN32) && defined(NTSD_EAS))
31+@@ -2023,7 +2025,8 @@ static int TestExtraField(__G__ ef, ef_len)
32+ ebID = makeword(ef);
33+ ebLen = (unsigned)makeword(ef+EB_LEN);
34+
35+- if (ebLen > (ef_len - EB_HEADSIZE)) {
36++ if (ebLen > (ef_len - EB_HEADSIZE))
37++ {
38+ /* Discovered some extra field inconsistency! */
39+ if (uO.qflag)
40+ Info(slide, 1, ((char *)slide, "%-22s ",
41+@@ -2158,11 +2161,19 @@ static int TestExtraField(__G__ ef, ef_len)
42+ }
43+ break;
44+ case EF_PKVMS:
45+- if (makelong(ef+EB_HEADSIZE) !=
46++ if (ebLen < 4)
47++ {
48++ Info(slide, 1,
49++ ((char *)slide, LoadFarString(TooSmallEBlength),
50++ ebLen, 4));
51++ }
52++ else if (makelong(ef+EB_HEADSIZE) !=
53+ crc32(CRCVAL_INITIAL, ef+(EB_HEADSIZE+4),
54+ (extent)(ebLen-4)))
55++ {
56+ Info(slide, 1, ((char *)slide,
57+ LoadFarString(BadCRC_EAs)));
58++ }
59+ break;
60+ case EF_PKW32:
61+ case EF_PKUNIX:
62+--
63+2.20.1
64+
1@@ -0,0 +1,38 @@
2+From a8ce86155076505d0d6e3d8a3e44c26bb89d9524 Mon Sep 17 00:00:00 2001
3+From: "Steven M. Schweda" <sms@antinode.info>
4+Date: Sat, 15 Jun 2019 18:13:11 -0700
5+Subject: [PATCH] Fix CVE-2014-8140: out-of-bounds write issue in
6+ test_compr_eb()
7+
8+---
9+ extract.c | 13 ++++++++++---
10+ 1 file changed, 10 insertions(+), 3 deletions(-)
11+
12+diff --git a/extract.c b/extract.c
13+index df0fa1c..ec31e60 100644
14+--- a/extract.c
15++++ b/extract.c
16+@@ -2232,10 +2232,17 @@ static int test_compr_eb(__G__ eb, eb_size, compr_offset, test_uc_ebdata)
17+ if (compr_offset < 4) /* field is not compressed: */
18+ return PK_OK; /* do nothing and signal OK */
19+
20++ /* Return no/bad-data error status if any problem is found:
21++ * 1. eb_size is too small to hold the uncompressed size
22++ * (eb_ucsize). (Else extract eb_ucsize.)
23++ * 2. eb_ucsize is zero (invalid). 2014-12-04 SMS.
24++ * 3. eb_ucsize is positive, but eb_size is too small to hold
25++ * the compressed data header.
26++ */
27+ if ((eb_size < (EB_UCSIZE_P + 4)) ||
28+- ((eb_ucsize = makelong(eb+(EB_HEADSIZE+EB_UCSIZE_P))) > 0L &&
29+- eb_size <= (compr_offset + EB_CMPRHEADLEN)))
30+- return IZ_EF_TRUNC; /* no compressed data! */
31++ ((eb_ucsize = makelong( eb+ (EB_HEADSIZE+ EB_UCSIZE_P))) == 0L) ||
32++ ((eb_ucsize > 0L) && (eb_size <= (compr_offset + EB_CMPRHEADLEN))))
33++ return IZ_EF_TRUNC; /* no/bad compressed data! */
34+
35+ if (
36+ #ifdef INT_16BIT
37+--
38+2.20.1
39+
1@@ -0,0 +1,151 @@
2+From 0bec3de89a03c7c998b755ff6091ab1e0f6c43b7 Mon Sep 17 00:00:00 2001
3+From: "Steven M. Schweda" <sms@antinode.info>
4+Date: Sat, 15 Jun 2019 18:13:11 -0700
5+Subject: [PATCH] Fix CVE-2014-8141: out-of-bounds read issues in
6+ getZip64Data()
7+
8+---
9+ fileio.c | 9 +++++++-
10+ process.c | 68 +++++++++++++++++++++++++++++++++++++++++--------------
11+ 2 files changed, 59 insertions(+), 18 deletions(-)
12+
13+diff --git a/fileio.c b/fileio.c
14+index ba0a1d0..36bfea3 100644
15+--- a/fileio.c
16++++ b/fileio.c
17+@@ -176,6 +176,8 @@ static ZCONST char Far FilenameTooLongTrunc[] =
18+ #endif
19+ static ZCONST char Far ExtraFieldTooLong[] =
20+ "warning: extra field too long (%d). Ignoring...\n";
21++static ZCONST char Far ExtraFieldCorrupt[] =
22++ "warning: extra field (type: 0x%04x) corrupt. Continuing...\n";
23+
24+ #ifdef WINDLL
25+ static ZCONST char Far DiskFullQuery[] =
26+@@ -2295,7 +2297,12 @@ int do_string(__G__ length, option) /* return PK-type error code */
27+ if (readbuf(__G__ (char *)G.extra_field, length) == 0)
28+ return PK_EOF;
29+ /* Looks like here is where extra fields are read */
30+- getZip64Data(__G__ G.extra_field, length);
31++ if (getZip64Data(__G__ G.extra_field, length) != PK_COOL)
32++ {
33++ Info(slide, 0x401, ((char *)slide,
34++ LoadFarString( ExtraFieldCorrupt), EF_PKSZ64));
35++ error = PK_WARN;
36++ }
37+ #ifdef UNICODE_SUPPORT
38+ G.unipath_filename = NULL;
39+ if (G.UzO.U_flag < 2) {
40+diff --git a/process.c b/process.c
41+index 3228bde..df683ea 100644
42+--- a/process.c
43++++ b/process.c
44+@@ -1,5 +1,5 @@
45+ /*
46+- Copyright (c) 1990-2009 Info-ZIP. All rights reserved.
47++ Copyright (c) 1990-2014 Info-ZIP. All rights reserved.
48+
49+ See the accompanying file LICENSE, version 2009-Jan-02 or later
50+ (the contents of which are also included in unzip.h) for terms of use.
51+@@ -1901,48 +1901,82 @@ int getZip64Data(__G__ ef_buf, ef_len)
52+ and a 4-byte version of disk start number.
53+ Sets both local header and central header fields. Not terribly clever,
54+ but it means that this procedure is only called in one place.
55++
56++ 2014-12-05 SMS.
57++ Added checks to ensure that enough data are available before calling
58++ makeint64() or makelong(). Replaced various sizeof() values with
59++ simple ("4" or "8") constants. (The Zip64 structures do not depend
60++ on our variable sizes.) Error handling is crude, but we should now
61++ stay within the buffer.
62+ ---------------------------------------------------------------------------*/
63+
64++#define Z64FLGS 0xffff
65++#define Z64FLGL 0xffffffff
66++
67+ if (ef_len == 0 || ef_buf == NULL)
68+ return PK_COOL;
69+
70+ Trace((stderr,"\ngetZip64Data: scanning extra field of length %u\n",
71+ ef_len));
72+
73+- while (ef_len >= EB_HEADSIZE) {
74++ while (ef_len >= EB_HEADSIZE)
75++ {
76+ eb_id = makeword(EB_ID + ef_buf);
77+ eb_len = makeword(EB_LEN + ef_buf);
78+
79+- if (eb_len > (ef_len - EB_HEADSIZE)) {
80+- /* discovered some extra field inconsistency! */
81++ if (eb_len > (ef_len - EB_HEADSIZE))
82++ {
83++ /* Extra block length exceeds remaining extra field length. */
84+ Trace((stderr,
85+ "getZip64Data: block length %u > rest ef_size %u\n", eb_len,
86+ ef_len - EB_HEADSIZE));
87+ break;
88+ }
89+- if (eb_id == EF_PKSZ64) {
90+-
91++ if (eb_id == EF_PKSZ64)
92++ {
93+ int offset = EB_HEADSIZE;
94+
95+- if (G.crec.ucsize == 0xffffffff || G.lrec.ucsize == 0xffffffff){
96+- G.lrec.ucsize = G.crec.ucsize = makeint64(offset + ef_buf);
97+- offset += sizeof(G.crec.ucsize);
98++ if ((G.crec.ucsize == Z64FLGL) || (G.lrec.ucsize == Z64FLGL))
99++ {
100++ if (offset+ 8 > ef_len)
101++ return PK_ERR;
102++
103++ G.crec.ucsize = G.lrec.ucsize = makeint64(offset + ef_buf);
104++ offset += 8;
105+ }
106+- if (G.crec.csize == 0xffffffff || G.lrec.csize == 0xffffffff){
107+- G.csize = G.lrec.csize = G.crec.csize = makeint64(offset + ef_buf);
108+- offset += sizeof(G.crec.csize);
109++
110++ if ((G.crec.csize == Z64FLGL) || (G.lrec.csize == Z64FLGL))
111++ {
112++ if (offset+ 8 > ef_len)
113++ return PK_ERR;
114++
115++ G.csize = G.crec.csize = G.lrec.csize = makeint64(offset + ef_buf);
116++ offset += 8;
117+ }
118+- if (G.crec.relative_offset_local_header == 0xffffffff){
119++
120++ if (G.crec.relative_offset_local_header == Z64FLGL)
121++ {
122++ if (offset+ 8 > ef_len)
123++ return PK_ERR;
124++
125+ G.crec.relative_offset_local_header = makeint64(offset + ef_buf);
126+- offset += sizeof(G.crec.relative_offset_local_header);
127++ offset += 8;
128+ }
129+- if (G.crec.disk_number_start == 0xffff){
130++
131++ if (G.crec.disk_number_start == Z64FLGS)
132++ {
133++ if (offset+ 4 > ef_len)
134++ return PK_ERR;
135++
136+ G.crec.disk_number_start = (zuvl_t)makelong(offset + ef_buf);
137+- offset += sizeof(G.crec.disk_number_start);
138++ offset += 4;
139+ }
140++#if 0
141++ break; /* Expect only one EF_PKSZ64 block. */
142++#endif /* 0 */
143+ }
144+
145+- /* Skip this extra field block */
146++ /* Skip this extra field block. */
147+ ef_buf += (eb_len + EB_HEADSIZE);
148+ ef_len -= (eb_len + EB_HEADSIZE);
149+ }
150+--
151+2.20.1
152+
1@@ -0,0 +1,48 @@
2+From 14342a8a5ddafa76a8aa9800da078d415f50af71 Mon Sep 17 00:00:00 2001
3+From: mancha <mancha1@zoho.com>
4+Date: Wed, 11 Feb 2015 12:27:06 +0000
5+Subject: [PATCH] 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+ extract.c | 10 ++++++++++
17+ 1 file changed, 10 insertions(+)
18+
19+diff --git a/extract.c b/extract.c
20+index ec31e60..f951b9f 100644
21+--- a/extract.c
22++++ b/extract.c
23+@@ -2228,6 +2228,7 @@ static int test_compr_eb(__G__ eb, eb_size, compr_offset, test_uc_ebdata)
24+ ulg eb_ucsize;
25+ uch *eb_ucptr;
26+ int r;
27++ ush eb_compr_method;
28+
29+ if (compr_offset < 4) /* field is not compressed: */
30+ return PK_OK; /* do nothing and signal OK */
31+@@ -2244,6 +2245,15 @@ static int test_compr_eb(__G__ eb, eb_size, compr_offset, test_uc_ebdata)
32+ ((eb_ucsize > 0L) && (eb_size <= (compr_offset + EB_CMPRHEADLEN))))
33+ return IZ_EF_TRUNC; /* no/bad compressed data! */
34+
35++ /* 2015-02-10 Mancha(?), Michal Zalewski, Tomas Hoger, SMS.
36++ * For STORE method, compressed and uncompressed sizes must agree.
37++ * http://www.info-zip.org/phpBB3/viewtopic.php?f=7&t=450
38++ */
39++ eb_compr_method = makeword( eb + (EB_HEADSIZE + compr_offset));
40++ if ((eb_compr_method == STORED) &&
41++ (eb_size != compr_offset + EB_CMPRHEADLEN + eb_ucsize))
42++ return PK_ERR;
43++
44+ if (
45+ #ifdef INT_16BIT
46+ (((ulg)(extent)eb_ucsize) != eb_ucsize) ||
47+--
48+2.20.1
49+
1@@ -0,0 +1,25 @@
2+From f6fa609c9074df6df59023e032f5397c44b40e8d Mon Sep 17 00:00:00 2001
3+From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Bobbio?= <lunar@debian.org>
4+Date: Sat, 15 Jun 2019 18:13:11 -0700
5+Subject: [PATCH] Remove build date
6+
7+---
8+ unix/unix.c | 2 +-
9+ 1 file changed, 1 insertion(+), 1 deletion(-)
10+
11+diff --git a/unix/unix.c b/unix/unix.c
12+index efa97fc..816e3da 100644
13+--- a/unix/unix.c
14++++ b/unix/unix.c
15+@@ -1705,7 +1705,7 @@ void version(__G)
16+ #endif /* Sun */
17+ #endif /* SGI */
18+
19+-#ifdef __DATE__
20++#if 0
21+ " on ", __DATE__
22+ #else
23+ "", ""
24+--
25+2.20.1
26+
1@@ -0,0 +1,35 @@
2+From d97748a061a3beb8bdf4d5d0a2458086951960ff Mon Sep 17 00:00:00 2001
3+From: Petr Stodulka <pstodulk@redhat.com>
4+Date: Mon, 14 Sep 2015 18:23:17 +0200
5+Subject: [PATCH] Upstream fix for heap overflow
6+
7+---
8+ crypt.c | 12 +++++++++++-
9+ 1 file changed, 11 insertions(+), 1 deletion(-)
10+
11+diff --git a/crypt.c b/crypt.c
12+index 784e411..a8975f2 100644
13+--- a/crypt.c
14++++ b/crypt.c
15+@@ -465,7 +465,17 @@ int decrypt(__G__ passwrd)
16+ GLOBAL(pInfo->encrypted) = FALSE;
17+ defer_leftover_input(__G);
18+ for (n = 0; n < RAND_HEAD_LEN; n++) {
19+- b = NEXTBYTE;
20++ /* 2012-11-23 SMS. (OUSPG report.)
21++ * Quit early if compressed size < HEAD_LEN. The resulting
22++ * error message ("unable to get password") could be improved,
23++ * but it's better than trying to read nonexistent data, and
24++ * then continuing with a negative G.csize. (See
25++ * fileio.c:readbyte()).
26++ */
27++ if ((b = NEXTBYTE) == (ush)EOF)
28++ {
29++ return PK_ERR;
30++ }
31+ h[n] = (uch)b;
32+ Trace((stdout, " (%02x)", h[n]));
33+ }
34+--
35+2.20.1
36+
1@@ -0,0 +1,29 @@
2+From e646271050da793fe50fe829b465c4e692fb7d53 Mon Sep 17 00:00:00 2001
3+From: Kamil Dudka <kdudka@redhat.com>
4+Date: Mon, 14 Sep 2015 18:24:56 +0200
5+Subject: [PATCH] fix infinite loop when extracting empty bzip2 data
6+
7+---
8+ extract.c | 6 ++++++
9+ 1 file changed, 6 insertions(+)
10+
11+diff --git a/extract.c b/extract.c
12+index f951b9f..188f1cf 100644
13+--- a/extract.c
14++++ b/extract.c
15+@@ -2729,6 +2729,12 @@ __GDEF
16+ int repeated_buf_err;
17+ bz_stream bstrm;
18+
19++ if (G.incnt <= 0 && G.csize <= 0L) {
20++ /* avoid an infinite loop */
21++ Trace((stderr, "UZbunzip2() got empty input\n"));
22++ return 2;
23++ }
24++
25+ #if (defined(DLL) && !defined(NO_SLIDE_REDIR))
26+ if (G.redirect_slide)
27+ wsize = G.redirect_size, redirSlide = G.redirect_buffer;
28+--
29+2.20.1
30+
1@@ -0,0 +1,36 @@
2+From c2b00ce1582efdb781355dfa7b161b5393cfa56f Mon Sep 17 00:00:00 2001
3+From: Kamil Dudka <kdudka@redhat.com>
4+Date: Tue, 22 Sep 2015 18:52:23 +0200
5+Subject: [PATCH] extract: prevent unsigned overflow on invalid input
6+
7+Suggested-by: Stefan Cornelius
8+---
9+ extract.c | 11 ++++++++++-
10+ 1 file changed, 10 insertions(+), 1 deletion(-)
11+
12+diff --git a/extract.c b/extract.c
13+index 188f1cf..549a5eb 100644
14+--- a/extract.c
15++++ b/extract.c
16+@@ -1257,8 +1257,17 @@ static int extract_or_test_entrylist(__G__ numchunk,
17+ if (G.lrec.compression_method == STORED) {
18+ zusz_t csiz_decrypted = G.lrec.csize;
19+
20+- if (G.pInfo->encrypted)
21++ if (G.pInfo->encrypted) {
22++ if (csiz_decrypted < 12) {
23++ /* handle the error now to prevent unsigned overflow */
24++ Info(slide, 0x401, ((char *)slide,
25++ LoadFarStringSmall(ErrUnzipNoFile),
26++ LoadFarString(InvalidComprData),
27++ LoadFarStringSmall2(Inflate)));
28++ return PK_ERR;
29++ }
30+ csiz_decrypted -= 12;
31++ }
32+ if (G.lrec.ucsize != csiz_decrypted) {
33+ Info(slide, 0x401, ((char *)slide,
34+ LoadFarStringSmall2(WrnStorUCSizCSizDiff),
35+--
36+2.20.1
37+
1@@ -0,0 +1,50 @@
2+From 528161b86e74c3afbe640c70761e6734119bea1c Mon Sep 17 00:00:00 2001
3+From: "Steven M. Schweda" <sms@antinode.info>
4+Date: Sat, 15 Jun 2019 18:13:11 -0700
5+Subject: [PATCH] Do not ignore extra fields containing Unix Timestamps
6+
7+---
8+ process.c | 11 +++++++----
9+ 1 file changed, 7 insertions(+), 4 deletions(-)
10+
11+diff --git a/process.c b/process.c
12+index df683ea..e4f2405 100644
13+--- a/process.c
14++++ b/process.c
15+@@ -2914,10 +2914,13 @@ unsigned ef_scan_for_izux(ef_buf, ef_len, ef_is_c, dos_mdatetime,
16+ break;
17+
18+ case EF_IZUNIX2:
19+- if (have_new_type_eb == 0) {
20+- flags &= ~0x0ff; /* ignore any previous IZUNIX field */
21++ if (have_new_type_eb == 0) { /* (< 1) */
22+ have_new_type_eb = 1;
23+ }
24++ if (have_new_type_eb <= 1) {
25++ /* Ignore any prior (EF_IZUNIX/EF_PKUNIX) UID/GID. */
26++ flags &= 0x0ff;
27++ }
28+ #ifdef IZ_HAVE_UXUIDGID
29+ if (have_new_type_eb > 1)
30+ break; /* IZUNIX3 overrides IZUNIX2 e.f. block ! */
31+@@ -2933,6 +2936,8 @@ unsigned ef_scan_for_izux(ef_buf, ef_len, ef_is_c, dos_mdatetime,
32+ /* new 3rd generation Unix ef */
33+ have_new_type_eb = 2;
34+
35++ /* Ignore any prior EF_IZUNIX/EF_PKUNIX/EF_IZUNIX2 UID/GID. */
36++ flags &= 0x0ff;
37+ /*
38+ Version 1 byte version of this extra field, currently 1
39+ UIDSize 1 byte Size of UID field
40+@@ -2953,8 +2958,6 @@ unsigned ef_scan_for_izux(ef_buf, ef_len, ef_is_c, dos_mdatetime,
41+ uid_size = *((EB_HEADSIZE + 1) + ef_buf);
42+ gid_size = *((EB_HEADSIZE + uid_size + 2) + ef_buf);
43+
44+- flags &= ~0x0ff; /* ignore any previous UNIX field */
45+-
46+ if ( read_ux3_value((EB_HEADSIZE + 2) + ef_buf,
47+ uid_size, &z_uidgid[0])
48+ &&
49+--
50+2.20.1
51+
1@@ -0,0 +1,36 @@
2+From 27b0cd89656d39266da7dcab7eb1812dcfc34192 Mon Sep 17 00:00:00 2001
3+From: "Steven M. Schweda" <sms@antinode.info>
4+Date: Sat, 15 Jun 2019 18:13:11 -0700
5+Subject: [PATCH] Fix CVE-2014-9913, buffer overflow in unzip
6+
7+---
8+ list.c | 13 ++++++++++++-
9+ 1 file changed, 12 insertions(+), 1 deletion(-)
10+
11+diff --git a/list.c b/list.c
12+index 5de41e5..e488109 100644
13+--- a/list.c
14++++ b/list.c
15+@@ -339,7 +339,18 @@ int list_files(__G) /* return PK-type error code */
16+ G.crec.compression_method == ENHDEFLATED) {
17+ methbuf[5] = dtype[(G.crec.general_purpose_bit_flag>>1) & 3];
18+ } else if (methnum >= NUM_METHODS) {
19+- sprintf(&methbuf[4], "%03u", G.crec.compression_method);
20++ /* 2013-02-26 SMS.
21++ * http://sourceforge.net/p/infozip/bugs/27/ CVE-2014-9913.
22++ * Unexpectedly large compression methods overflow
23++ * &methbuf[]. Use the old, three-digit decimal format
24++ * for values which fit. Otherwise, sacrifice the
25++ * colon, and use four-digit hexadecimal.
26++ */
27++ if (G.crec.compression_method <= 999) {
28++ sprintf( &methbuf[ 4], "%03u", G.crec.compression_method);
29++ } else {
30++ sprintf( &methbuf[ 3], "%04X", G.crec.compression_method);
31++ }
32+ }
33+
34+ #if 0 /* GRR/Euro: add this? */
35+--
36+2.20.1
37+
1@@ -0,0 +1,36 @@
2+From 7e0435546230ecebe3bfe1ac27eb0186c702c509 Mon Sep 17 00:00:00 2001
3+From: "Steven M. Schweda" <sms@antinode.info>
4+Date: Sat, 15 Jun 2019 18:13:11 -0700
5+Subject: [PATCH] Fix CVE-2016-9844, buffer overflow in zipinfo
6+
7+---
8+ zipinfo.c | 13 ++++++++++++-
9+ 1 file changed, 12 insertions(+), 1 deletion(-)
10+
11+diff --git a/zipinfo.c b/zipinfo.c
12+index 5e77018..0be3e5b 100644
13+--- a/zipinfo.c
14++++ b/zipinfo.c
15+@@ -1921,7 +1921,18 @@ static int zi_short(__G) /* return PK-type error code */
16+ ush dnum=(ush)((G.crec.general_purpose_bit_flag>>1) & 3);
17+ methbuf[3] = dtype[dnum];
18+ } else if (methnum >= NUM_METHODS) { /* unknown */
19+- sprintf(&methbuf[1], "%03u", G.crec.compression_method);
20++ /* 2016-12-05 SMS.
21++ * https://launchpad.net/bugs/1643750
22++ * Unexpectedly large compression methods overflow
23++ * &methbuf[]. Use the old, three-digit decimal format
24++ * for values which fit. Otherwise, sacrifice the "u",
25++ * and use four-digit hexadecimal.
26++ */
27++ if (G.crec.compression_method <= 999) {
28++ sprintf( &methbuf[ 1], "%03u", G.crec.compression_method);
29++ } else {
30++ sprintf( &methbuf[ 0], "%04X", G.crec.compression_method);
31++ }
32+ }
33+
34+ for (k = 0; k < 15; ++k)
35+--
36+2.20.1
37+
1@@ -0,0 +1,44 @@
2+From d8d3475850d883e90d79086293279149d42658fd Mon Sep 17 00:00:00 2001
3+From: Karol Babioch <kbabioch@suse.com>
4+Date: Sat, 15 Jun 2019 18:13:11 -0700
5+Subject: [PATCH] Fix buffer overflow in password protected zip archives
6+
7+---
8+ fileio.c | 14 +++++++++++++-
9+ 1 file changed, 13 insertions(+), 1 deletion(-)
10+
11+diff --git a/fileio.c b/fileio.c
12+index 36bfea3..7c21ed0 100644
13+--- a/fileio.c
14++++ b/fileio.c
15+@@ -1582,6 +1582,10 @@ int UZ_EXP UzpPassword (pG, rcnt, pwbuf, size, zfn, efn)
16+ int r = IZ_PW_ENTERED;
17+ char *m;
18+ char *prompt;
19++ char *zfnf;
20++ char *efnf;
21++ size_t zfnfl;
22++ int isOverflow;
23+
24+ #ifndef REENTRANT
25+ /* tell picky compilers to shut up about "unused variable" warnings */
26+@@ -1590,7 +1594,15 @@ int UZ_EXP UzpPassword (pG, rcnt, pwbuf, size, zfn, efn)
27+
28+ if (*rcnt == 0) { /* First call for current entry */
29+ *rcnt = 2;
30+- if ((prompt = (char *)malloc(2*FILNAMSIZ + 15)) != (char *)NULL) {
31++ zfnf = FnFilter1(zfn);
32++ efnf = FnFilter2(efn);
33++ zfnfl = strlen(zfnf);
34++ isOverflow = TRUE;
35++ if (2*FILNAMSIZ >= zfnfl && (2*FILNAMSIZ - zfnfl) >= strlen(efnf))
36++ {
37++ isOverflow = FALSE;
38++ }
39++ if ((isOverflow == FALSE) && ((prompt = (char *)malloc(2*FILNAMSIZ + 15)) != (char *)NULL)) {
40+ sprintf(prompt, LoadFarString(PasswPrompt),
41+ FnFilter1(zfn), FnFilter2(efn));
42+ m = prompt;
43+--
44+2.20.1
45+
1@@ -0,0 +1,24 @@
2+From 365c0c559506ce300793fe469394ca748dd81b50 Mon Sep 17 00:00:00 2001
3+From: "Steven M. Schweda" <sms@antinode.info>
4+Date: Sat, 15 Jun 2019 18:13:11 -0700
5+Subject: [PATCH] Fix lame code in fileio.c
6+
7+---
8+ fileio.c | 1 +
9+ 1 file changed, 1 insertion(+)
10+
11+diff --git a/fileio.c b/fileio.c
12+index 7c21ed0..c10ff63 100644
13+--- a/fileio.c
14++++ b/fileio.c
15+@@ -2477,6 +2477,7 @@ zusz_t makeint64(sig)
16+ */
17+ return (((zusz_t)sig[7]) << 56)
18+ + (((zusz_t)sig[6]) << 48)
19++ + (((zusz_t)sig[5]) << 40)
20+ + (((zusz_t)sig[4]) << 32)
21+ + (zusz_t)((((ulg)sig[3]) << 24)
22+ + (((ulg)sig[2]) << 16)
23+--
24+2.20.1
25+
1@@ -0,0 +1,29 @@
2+From 3eda39fac98550990abb9f83d986619d173f9605 Mon Sep 17 00:00:00 2001
3+From: Mark Adler <madler@alumni.caltech.edu>
4+Date: Fri, 31 Jan 2020 22:05:56 -0800
5+Subject: [PATCH] Fix bug in undefer_input() that misplaced the input state.
6+
7+ Fix bug in undefer_input() that misplaced the input state.
8+---
9+ fileio.c | 4 +++-
10+ 1 file changed, 3 insertions(+), 1 deletion(-)
11+
12+diff --git a/fileio.c b/fileio.c
13+index c10ff63..6290824 100644
14+--- a/fileio.c
15++++ b/fileio.c
16+@@ -532,8 +532,10 @@ void undefer_input(__G)
17+ * This condition was checked when G.incnt_leftover was set > 0 in
18+ * defer_leftover_input(), and it is NOT allowed to touch G.csize
19+ * before calling undefer_input() when (G.incnt_leftover > 0)
20+- * (single exception: see read_byte()'s "G.csize <= 0" handling) !!
21++ * (single exception: see readbyte()'s "G.csize <= 0" handling) !!
22+ */
23++ if (G.csize < 0L)
24++ G.csize = 0L;
25+ G.incnt = G.incnt_leftover + (int)G.csize;
26+ G.inptr = G.inptr_leftover - (int)G.csize;
27+ G.incnt_leftover = 0;
28+--
29+2.25.0
30+
1@@ -0,0 +1,354 @@
2+From 6cdb7b372b4d46e06a982c6f3494c086d2418c7b Mon Sep 17 00:00:00 2001
3+From: Mark Adler <madler@alumni.caltech.edu>
4+Date: Fri, 31 Jan 2020 22:05:59 -0800
5+Subject: [PATCH] Detect and reject a zip bomb using overlapped entries.
6+
7+ Detect and reject a zip bomb using overlapped entries.
8+
9+ This detects an invalid zip file that has at least one entry that
10+ overlaps with another entry or with the central directory to the
11+ end of the file. A Fifield zip bomb uses overlapped local entries
12+ to vastly increase the potential inflation ratio. Such an invalid
13+ zip file is rejected.
14+
15+ See https://www.bamsoftware.com/hacks/zipbomb/ for David Fifield's
16+ analysis, construction, and examples of such zip bombs.
17+
18+ The detection maintains a list of covered spans of the zip files
19+ so far, where the central directory to the end of the file and any
20+ bytes preceding the first entry at zip file offset zero are
21+ considered covered initially. Then as each entry is decompressed
22+ or tested, it is considered covered. When a new entry is about to
23+ be processed, its initial offset is checked to see if it is
24+ contained by a covered span. If so, the zip file is rejected as
25+ invalid.
26+
27+ This commit depends on a preceding commit: "Fix bug in
28+ undefer_input() that misplaced the input state."
29+---
30+ extract.c | 190 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
31+ globals.c | 1 +
32+ globals.h | 3 +
33+ process.c | 11 ++++
34+ unzip.h | 1 +
35+ 5 files changed, 205 insertions(+), 1 deletion(-)
36+
37+diff --git a/extract.c b/extract.c
38+index 549a5eb..1f078d1 100644
39+--- a/extract.c
40++++ b/extract.c
41+@@ -321,6 +321,125 @@ static ZCONST char Far UnsupportedExtraField[] =
42+ "\nerror: unsupported extra-field compression type (%u)--skipping\n";
43+ static ZCONST char Far BadExtraFieldCRC[] =
44+ "error [%s]: bad extra-field CRC %08lx (should be %08lx)\n";
45++static ZCONST char Far NotEnoughMemCover[] =
46++ "error: not enough memory for bomb detection\n";
47++static ZCONST char Far OverlappedComponents[] =
48++ "error: invalid zip file with overlapped components (possible zip bomb)\n";
49++
50++
51++
52++
53++
54++/* A growable list of spans. */
55++typedef zoff_t bound_t;
56++typedef struct {
57++ bound_t beg; /* start of the span */
58++ bound_t end; /* one past the end of the span */
59++} span_t;
60++typedef struct {
61++ span_t *span; /* allocated, distinct, and sorted list of spans */
62++ size_t num; /* number of spans in the list */
63++ size_t max; /* allocated number of spans (num <= max) */
64++} cover_t;
65++
66++/*
67++ * Return the index of the first span in cover whose beg is greater than val.
68++ * If there is no such span, then cover->num is returned.
69++ */
70++static size_t cover_find(cover, val)
71++ cover_t *cover;
72++ bound_t val;
73++{
74++ size_t lo = 0, hi = cover->num;
75++ while (lo < hi) {
76++ size_t mid = (lo + hi) >> 1;
77++ if (val < cover->span[mid].beg)
78++ hi = mid;
79++ else
80++ lo = mid + 1;
81++ }
82++ return hi;
83++}
84++
85++/* Return true if val lies within any one of the spans in cover. */
86++static int cover_within(cover, val)
87++ cover_t *cover;
88++ bound_t val;
89++{
90++ size_t pos = cover_find(cover, val);
91++ return pos > 0 && val < cover->span[pos - 1].end;
92++}
93++
94++/*
95++ * Add a new span to the list, but only if the new span does not overlap any
96++ * spans already in the list. The new span covers the values beg..end-1. beg
97++ * must be less than end.
98++ *
99++ * Keep the list sorted and merge adjacent spans. Grow the allocated space for
100++ * the list as needed. On success, 0 is returned. If the new span overlaps any
101++ * existing spans, then 1 is returned and the new span is not added to the
102++ * list. If the new span is invalid because beg is greater than or equal to
103++ * end, then -1 is returned. If the list needs to be grown but the memory
104++ * allocation fails, then -2 is returned.
105++ */
106++static int cover_add(cover, beg, end)
107++ cover_t *cover;
108++ bound_t beg;
109++ bound_t end;
110++{
111++ size_t pos;
112++ int prec, foll;
113++
114++ if (beg >= end)
115++ /* The new span is invalid. */
116++ return -1;
117++
118++ /* Find where the new span should go, and make sure that it does not
119++ overlap with any existing spans. */
120++ pos = cover_find(cover, beg);
121++ if ((pos > 0 && beg < cover->span[pos - 1].end) ||
122++ (pos < cover->num && end > cover->span[pos].beg))
123++ return 1;
124++
125++ /* Check for adjacencies. */
126++ prec = pos > 0 && beg == cover->span[pos - 1].end;
127++ foll = pos < cover->num && end == cover->span[pos].beg;
128++ if (prec && foll) {
129++ /* The new span connects the preceding and following spans. Merge the
130++ following span into the preceding span, and delete the following
131++ span. */
132++ cover->span[pos - 1].end = cover->span[pos].end;
133++ cover->num--;
134++ memmove(cover->span + pos, cover->span + pos + 1,
135++ (cover->num - pos) * sizeof(span_t));
136++ }
137++ else if (prec)
138++ /* The new span is adjacent only to the preceding span. Extend the end
139++ of the preceding span. */
140++ cover->span[pos - 1].end = end;
141++ else if (foll)
142++ /* The new span is adjacent only to the following span. Extend the
143++ beginning of the following span. */
144++ cover->span[pos].beg = beg;
145++ else {
146++ /* The new span has gaps between both the preceding and the following
147++ spans. Assure that there is room and insert the span. */
148++ if (cover->num == cover->max) {
149++ size_t max = cover->max == 0 ? 16 : cover->max << 1;
150++ span_t *span = realloc(cover->span, max * sizeof(span_t));
151++ if (span == NULL)
152++ return -2;
153++ cover->span = span;
154++ cover->max = max;
155++ }
156++ memmove(cover->span + pos + 1, cover->span + pos,
157++ (cover->num - pos) * sizeof(span_t));
158++ cover->num++;
159++ cover->span[pos].beg = beg;
160++ cover->span[pos].end = end;
161++ }
162++ return 0;
163++}
164+
165+
166+
167+@@ -376,6 +495,29 @@ int extract_or_test_files(__G) /* return PK-type error code */
168+ }
169+ #endif /* !SFX || SFX_EXDIR */
170+
171++ /* One more: initialize cover structure for bomb detection. Start with a
172++ span that covers the central directory though the end of the file. */
173++ if (G.cover == NULL) {
174++ G.cover = malloc(sizeof(cover_t));
175++ if (G.cover == NULL) {
176++ Info(slide, 0x401, ((char *)slide,
177++ LoadFarString(NotEnoughMemCover)));
178++ return PK_MEM;
179++ }
180++ ((cover_t *)G.cover)->span = NULL;
181++ ((cover_t *)G.cover)->max = 0;
182++ }
183++ ((cover_t *)G.cover)->num = 0;
184++ if ((G.extra_bytes != 0 &&
185++ cover_add((cover_t *)G.cover, 0, G.extra_bytes) != 0) ||
186++ cover_add((cover_t *)G.cover,
187++ G.extra_bytes + G.ecrec.offset_start_central_directory,
188++ G.ziplen) != 0) {
189++ Info(slide, 0x401, ((char *)slide,
190++ LoadFarString(NotEnoughMemCover)));
191++ return PK_MEM;
192++ }
193++
194+ /*---------------------------------------------------------------------------
195+ The basic idea of this function is as follows. Since the central di-
196+ rectory lies at the end of the zipfile and the member files lie at the
197+@@ -593,7 +735,8 @@ int extract_or_test_files(__G) /* return PK-type error code */
198+ if (error > error_in_archive)
199+ error_in_archive = error;
200+ /* ...and keep going (unless disk full or user break) */
201+- if (G.disk_full > 1 || error_in_archive == IZ_CTRLC) {
202++ if (G.disk_full > 1 || error_in_archive == IZ_CTRLC ||
203++ error == PK_BOMB) {
204+ /* clear reached_end to signal premature stop ... */
205+ reached_end = FALSE;
206+ /* ... and cancel scanning the central directory */
207+@@ -1062,6 +1205,11 @@ static int extract_or_test_entrylist(__G__ numchunk,
208+
209+ /* seek_zipf(__G__ pInfo->offset); */
210+ request = G.pInfo->offset + G.extra_bytes;
211++ if (cover_within((cover_t *)G.cover, request)) {
212++ Info(slide, 0x401, ((char *)slide,
213++ LoadFarString(OverlappedComponents)));
214++ return PK_BOMB;
215++ }
216+ inbuf_offset = request % INBUFSIZ;
217+ bufstart = request - inbuf_offset;
218+
219+@@ -1602,6 +1750,18 @@ reprompt:
220+ return IZ_CTRLC; /* cancel operation by user request */
221+ }
222+ #endif
223++ error = cover_add((cover_t *)G.cover, request,
224++ G.cur_zipfile_bufstart + (G.inptr - G.inbuf));
225++ if (error < 0) {
226++ Info(slide, 0x401, ((char *)slide,
227++ LoadFarString(NotEnoughMemCover)));
228++ return PK_MEM;
229++ }
230++ if (error != 0) {
231++ Info(slide, 0x401, ((char *)slide,
232++ LoadFarString(OverlappedComponents)));
233++ return PK_BOMB;
234++ }
235+ #ifdef MACOS /* MacOS is no preemptive OS, thus call event-handling by hand */
236+ UserStop();
237+ #endif
238+@@ -2003,6 +2163,34 @@ static int extract_or_test_member(__G) /* return PK-type error code */
239+ }
240+
241+ undefer_input(__G);
242++
243++ if ((G.lrec.general_purpose_bit_flag & 8) != 0) {
244++ /* skip over data descriptor (harder than it sounds, due to signature
245++ * ambiguity)
246++ */
247++# define SIG 0x08074b50
248++# define LOW 0xffffffff
249++ uch buf[12];
250++ unsigned shy = 12 - readbuf((char *)buf, 12);
251++ ulg crc = shy ? 0 : makelong(buf);
252++ ulg clen = shy ? 0 : makelong(buf + 4);
253++ ulg ulen = shy ? 0 : makelong(buf + 8); /* or high clen if ZIP64 */
254++ if (crc == SIG && /* if not SIG, no signature */
255++ (G.lrec.crc32 != SIG || /* if not SIG, have signature */
256++ (clen == SIG && /* if not SIG, no signature */
257++ ((G.lrec.csize & LOW) != SIG || /* if not SIG, have signature */
258++ (ulen == SIG && /* if not SIG, no signature */
259++ (G.zip64 ? G.lrec.csize >> 32 : G.lrec.ucsize) != SIG
260++ /* if not SIG, have signature */
261++ )))))
262++ /* skip four more bytes to account for signature */
263++ shy += 4 - readbuf((char *)buf, 4);
264++ if (G.zip64)
265++ shy += 8 - readbuf((char *)buf, 8); /* skip eight more for ZIP64 */
266++ if (shy)
267++ error = PK_ERR;
268++ }
269++
270+ return error;
271+
272+ } /* end function extract_or_test_member() */
273+diff --git a/globals.c b/globals.c
274+index fa8cca5..1e0f608 100644
275+--- a/globals.c
276++++ b/globals.c
277+@@ -181,6 +181,7 @@ Uz_Globs *globalsCtor()
278+ # if (!defined(NO_TIMESTAMPS))
279+ uO.D_flag=1; /* default to '-D', no restoration of dir timestamps */
280+ # endif
281++ G.cover = NULL; /* not allocated yet */
282+ #endif
283+
284+ uO.lflag=(-1);
285+diff --git a/globals.h b/globals.h
286+index 11b7215..2bdcdeb 100644
287+--- a/globals.h
288++++ b/globals.h
289+@@ -260,12 +260,15 @@ typedef struct Globals {
290+ ecdir_rec ecrec; /* used in unzip.c, extract.c */
291+ z_stat statbuf; /* used by main, mapname, check_for_newer */
292+
293++ int zip64; /* true if Zip64 info in extra field */
294++
295+ int mem_mode;
296+ uch *outbufptr; /* extract.c static */
297+ ulg outsize; /* extract.c static */
298+ int reported_backslash; /* extract.c static */
299+ int disk_full;
300+ int newfile;
301++ void **cover; /* used in extract.c for bomb detection */
302+
303+ int didCRlast; /* fileio static */
304+ ulg numlines; /* fileio static: number of lines printed */
305+diff --git a/process.c b/process.c
306+index e4f2405..e4e7aee 100644
307+--- a/process.c
308++++ b/process.c
309+@@ -637,6 +637,13 @@ void free_G_buffers(__G) /* releases all memory allocated in global vars */
310+ }
311+ #endif
312+
313++ /* Free the cover span list and the cover structure. */
314++ if (G.cover != NULL) {
315++ free(*(G.cover));
316++ free(G.cover);
317++ G.cover = NULL;
318++ }
319++
320+ } /* end function free_G_buffers() */
321+
322+
323+@@ -1913,6 +1920,8 @@ int getZip64Data(__G__ ef_buf, ef_len)
324+ #define Z64FLGS 0xffff
325+ #define Z64FLGL 0xffffffff
326+
327++ G.zip64 = FALSE;
328++
329+ if (ef_len == 0 || ef_buf == NULL)
330+ return PK_COOL;
331+
332+@@ -2084,6 +2093,8 @@ int getUnicodeData(__G__ ef_buf, ef_len)
333+ (ZCONST char *)(offset + ef_buf), ULen);
334+ G.unipath_filename[ULen] = '\0';
335+ }
336++
337++ G.zip64 = TRUE;
338+ }
339+
340+ /* Skip this extra field block */
341+diff --git a/unzip.h b/unzip.h
342+index 5b2a326..ed24a5b 100644
343+--- a/unzip.h
344++++ b/unzip.h
345+@@ -645,6 +645,7 @@ typedef struct _Uzp_cdir_Rec {
346+ #define PK_NOZIP 9 /* zipfile not found */
347+ #define PK_PARAM 10 /* bad or illegal parameters specified */
348+ #define PK_FIND 11 /* no files found */
349++#define PK_BOMB 12 /* likely zip bomb */
350+ #define PK_DISK 50 /* disk full */
351+ #define PK_EOF 51 /* unexpected EOF */
352+
353+--
354+2.25.0
355+
1@@ -0,0 +1,117 @@
2+From 9d516b8c761d3816f946aa8937ebf9fadfe6a002 Mon Sep 17 00:00:00 2001
3+From: Mark Adler <madler@alumni.caltech.edu>
4+Date: Fri, 31 Jan 2020 22:06:02 -0800
5+Subject: [PATCH] Do not raise a zip bomb alert for a misplaced central
6+ directory.
7+
8+ Do not raise a zip bomb alert for a misplaced central directory.
9+
10+ There is a zip-like file in the Firefox distribution, omni.ja,
11+ which is a zip container with the central directory placed at the
12+ start of the file instead of after the local entries as required
13+ by the zip standard. This commit marks the actual location of the
14+ central directory, as well as the end of central directory records,
15+ as disallowed locations. This now permits such containers to not
16+ raise a zip bomb alert, where in fact there are no overlaps.
17+---
18+ extract.c | 25 +++++++++++++++++++------
19+ process.c | 6 ++++++
20+ unzpriv.h | 10 ++++++++++
21+ 3 files changed, 35 insertions(+), 6 deletions(-)
22+
23+diff --git a/extract.c b/extract.c
24+index 1f078d1..ad5daac 100644
25+--- a/extract.c
26++++ b/extract.c
27+@@ -495,8 +495,11 @@ int extract_or_test_files(__G) /* return PK-type error code */
28+ }
29+ #endif /* !SFX || SFX_EXDIR */
30+
31+- /* One more: initialize cover structure for bomb detection. Start with a
32+- span that covers the central directory though the end of the file. */
33++ /* One more: initialize cover structure for bomb detection. Start with
34++ spans that cover any extra bytes at the start, the central directory,
35++ the end of central directory record (including the Zip64 end of central
36++ directory locator, if present), and the Zip64 end of central directory
37++ record, if present. */
38+ if (G.cover == NULL) {
39+ G.cover = malloc(sizeof(cover_t));
40+ if (G.cover == NULL) {
41+@@ -508,15 +511,25 @@ int extract_or_test_files(__G) /* return PK-type error code */
42+ ((cover_t *)G.cover)->max = 0;
43+ }
44+ ((cover_t *)G.cover)->num = 0;
45+- if ((G.extra_bytes != 0 &&
46+- cover_add((cover_t *)G.cover, 0, G.extra_bytes) != 0) ||
47+- cover_add((cover_t *)G.cover,
48++ if (cover_add((cover_t *)G.cover,
49+ G.extra_bytes + G.ecrec.offset_start_central_directory,
50+- G.ziplen) != 0) {
51++ G.extra_bytes + G.ecrec.offset_start_central_directory +
52++ G.ecrec.size_central_directory) != 0) {
53+ Info(slide, 0x401, ((char *)slide,
54+ LoadFarString(NotEnoughMemCover)));
55+ return PK_MEM;
56+ }
57++ if ((G.extra_bytes != 0 &&
58++ cover_add((cover_t *)G.cover, 0, G.extra_bytes) != 0) ||
59++ (G.ecrec.have_ecr64 &&
60++ cover_add((cover_t *)G.cover, G.ecrec.ec64_start,
61++ G.ecrec.ec64_end) != 0) ||
62++ cover_add((cover_t *)G.cover, G.ecrec.ec_start,
63++ G.ecrec.ec_end) != 0) {
64++ Info(slide, 0x401, ((char *)slide,
65++ LoadFarString(OverlappedComponents)));
66++ return PK_BOMB;
67++ }
68+
69+ /*---------------------------------------------------------------------------
70+ The basic idea of this function is as follows. Since the central di-
71+diff --git a/process.c b/process.c
72+index e4e7aee..d2a846e 100644
73+--- a/process.c
74++++ b/process.c
75+@@ -1408,6 +1408,10 @@ static int find_ecrec64(__G__ searchlen) /* return PK-class error */
76+
77+ /* Now, we are (almost) sure that we have a Zip64 archive. */
78+ G.ecrec.have_ecr64 = 1;
79++ G.ecrec.ec_start -= ECLOC64_SIZE+4;
80++ G.ecrec.ec64_start = ecrec64_start_offset;
81++ G.ecrec.ec64_end = ecrec64_start_offset +
82++ 12 + makeint64(&byterec[ECREC64_LENGTH]);
83+
84+ /* Update the "end-of-central-dir offset" for later checks. */
85+ G.real_ecrec_offset = ecrec64_start_offset;
86+@@ -1542,6 +1546,8 @@ static int find_ecrec(__G__ searchlen) /* return PK-class error */
87+ makelong(&byterec[OFFSET_START_CENTRAL_DIRECTORY]);
88+ G.ecrec.zipfile_comment_length =
89+ makeword(&byterec[ZIPFILE_COMMENT_LENGTH]);
90++ G.ecrec.ec_start = G.real_ecrec_offset;
91++ G.ecrec.ec_end = G.ecrec.ec_start + 22 + G.ecrec.zipfile_comment_length;
92+
93+ /* Now, we have to read the archive comment, BEFORE the file pointer
94+ is moved away backwards to seek for a Zip64 ECLOC64 structure.
95+diff --git a/unzpriv.h b/unzpriv.h
96+index dc9eff5..297b3c7 100644
97+--- a/unzpriv.h
98++++ b/unzpriv.h
99+@@ -2185,6 +2185,16 @@ typedef struct VMStimbuf {
100+ int have_ecr64; /* valid Zip64 ecdir-record exists */
101+ int is_zip64_archive; /* Zip64 ecdir-record is mandatory */
102+ ush zipfile_comment_length;
103++ zusz_t ec_start, ec_end; /* offsets of start and end of the
104++ end of central directory record,
105++ including if present the Zip64
106++ end of central directory locator,
107++ which immediately precedes the
108++ end of central directory record */
109++ zusz_t ec64_start, ec64_end; /* if have_ecr64 is true, then these
110++ are the offsets of the start and
111++ end of the Zip64 end of central
112++ directory record */
113+ } ecdir_rec;
114+
115+
116+--
117+2.25.0
118+
1@@ -0,0 +1,25 @@
2+From f731106313a5edc37b5cbef93da6be855f24c238 Mon Sep 17 00:00:00 2001
3+From: Michael Forney <mforney@mforney.org>
4+Date: Sat, 15 Jun 2019 18:16:56 -0700
5+Subject: [PATCH] Use `long long` with C99 compilers
6+
7+---
8+ unzpriv.h | 2 +-
9+ 1 file changed, 1 insertion(+), 1 deletion(-)
10+
11+diff --git a/unzpriv.h b/unzpriv.h
12+index dc9eff5..8f18b87 100644
13+--- a/unzpriv.h
14++++ b/unzpriv.h
15+@@ -1904,7 +1904,7 @@
16+
17+ #ifdef ZIP64_SUPPORT
18+ # ifndef Z_UINT8_DEFINED
19+-# if (defined(__GNUC__) || defined(__hpux) || defined(__SUNPRO_C))
20++# if (defined(__GNUC__) || defined(__hpux) || defined(__SUNPRO_C) || __STDC_VERSION__ > 199901L)
21+ typedef unsigned long long z_uint8;
22+ # else
23+ typedef unsigned __int64 z_uint8;
24+--
25+2.20.1
26+
+1,
-0
1@@ -0,0 +1 @@
2+036d96991646d0449ed0aa952e4fbe21b476ce994abc276e49d30e686708bd37 unzip60.tar.gz
+0,
-0
+1,
-0
1@@ -0,0 +1 @@
2+url = "http://downloads.sourceforge.net/infozip/unzip60.tar.gz"
+1,
-0
1@@ -0,0 +1 @@
2+6.0-25 r0