pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

unzip: sync with archivers/unzip



Module Name:	pkgsrc-wip
Committed By:	kikadf <kikadf.01%gmail.com@localhost>
Pushed By:	kikadf
Date:		Sat Aug 23 15:10:35 2025 +0200
Changeset:	a969c04b0f93c004cd55f4d89e6c1b504c26dfab

Modified Files:
	unzip/Makefile
	unzip/PLIST
	unzip/distinfo
	unzip/patches/patch-ab
Added Files:
	unzip/patches/patch-ac
	unzip/patches/patch-crypt.c
	unzip/patches/patch-extract.c
	unzip/patches/patch-fileio.c
	unzip/patches/patch-globals.h
	unzip/patches/patch-list.c
	unzip/patches/patch-process.c
	unzip/patches/patch-unix_unxcfg.h
	unzip/patches/patch-zipinfo.c
Removed Files:
	unzip/TODO
	unzip/patches/patch-aa

Log Message:
unzip: sync with archivers/unzip

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=a969c04b0f93c004cd55f4d89e6c1b504c26dfab

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 unzip/Makefile                    |  24 +++--
 unzip/PLIST                       |   2 +-
 unzip/TODO                        |   1 -
 unzip/distinfo                    |  19 +++-
 unzip/patches/patch-aa            |  23 -----
 unzip/patches/patch-ab            |  14 +--
 unzip/patches/patch-ac            |  30 ++++++
 unzip/patches/patch-crypt.c       |  26 +++++
 unzip/patches/patch-extract.c     | 123 +++++++++++++++++++++++
 unzip/patches/patch-fileio.c      |  77 ++++++++++++++
 unzip/patches/patch-globals.h     |  21 ++++
 unzip/patches/patch-list.c        |  54 ++++++++++
 unzip/patches/patch-process.c     | 206 ++++++++++++++++++++++++++++++++++++++
 unzip/patches/patch-unix_unxcfg.h |  48 +++++++++
 unzip/patches/patch-zipinfo.c     |  27 +++++
 15 files changed, 650 insertions(+), 45 deletions(-)

diffs:
diff --git a/unzip/Makefile b/unzip/Makefile
index 3e30baf377..26a686ede0 100644
--- a/unzip/Makefile
+++ b/unzip/Makefile
@@ -1,12 +1,13 @@
-# $NetBSD: Makefile,v 1.2 2014/10/09 14:06:31 thomasklausner Exp $
+# $NetBSD: Makefile,v 1.101 2025/07/03 09:59:10 jperkin Exp $
 
-DISTNAME=	unzip610b
-PKGNAME=	unzip-6.10b
+DISTNAME=	unzip60
+PKGNAME=	unzip-6.0
+PKGREVISION=	10
 CATEGORIES=	archivers
-MASTER_SITES=	ftp://ftp.info-zip.org/pub/infozip/beta/
-EXTRACT_SUFX=	.zip
+MASTER_SITES=	ftp://ftp.info-zip.org/pub/infozip/src/
+EXTRACT_SUFX=	.tgz
 
-MAINTAINER=	wiz%NetBSD.org@localhost
+MAINTAINER=	pkgsrc-users%NetBSD.org@localhost
 HOMEPAGE=	http://www.info-zip.org/UnZip.html
 COMMENT=	List, test and extract compressed files in a ZIP archive
 LICENSE=	info-zip
@@ -29,10 +30,17 @@ CPPFLAGS+=	-DBSD
      ${OPSYS} == "OSF1"  || \
      ${OPSYS} == "AIX"  || \
      ${OPSYS} == "OpenBSD"  || \
-    (${OPSYS} == "Darwin" && !empty(OS_VERSION:M[01234678].*)))
+     ${OPSYS} == "Cygwin"  || \
+     ${OPSYS} == "UnixWare"  || \
+    (${OPSYS} == "Darwin" && !empty(OS_VERSION:M[01234678].*))) || \
+     ${OS_VARIANT} == "SCOOSR5" || \
+     ${OPSYS} == "Linux"
 CPPFLAGS+=	-DNO_LCHMOD
 .endif
-CPPFLAGS+=	-DLARGE_FILE_SUPPORT -DUNIX -Dunix -DUSE_UNSHRINK -I.
+CPPFLAGS+=	-DUNIX -Dunix -DUSE_UNSHRINK -I.
+.if !${MACHINE_PLATFORM:MSunOS-*-sparc}
+CPPFLAGS+=	-DLARGE_FILE_SUPPORT
+.endif
 
 MAKE_FLAGS+=	CF=${CPPFLAGS:Q}\ ${CFLAGS:Q}
 MAKE_FLAGS+=	LF2=${_STRIPFLAG_CC:Q}\ ${LDFLAGS:Q}\ -lz
diff --git a/unzip/PLIST b/unzip/PLIST
index 69f04a9e64..5b88f72004 100644
--- a/unzip/PLIST
+++ b/unzip/PLIST
@@ -1,4 +1,4 @@
-@comment $NetBSD: PLIST,v 1.1 2013/05/31 13:41:37 thomasklausner Exp $
+@comment $NetBSD: PLIST,v 1.4 2010/03/03 16:27:57 wiz Exp $
 bin/funzip
 bin/unzip
 bin/unzipsfx
diff --git a/unzip/TODO b/unzip/TODO
deleted file mode 100644
index 8b71421449..0000000000
--- a/unzip/TODO
+++ /dev/null
@@ -1 +0,0 @@
-Nothing to do, just wait for a proper release -- this is a beta version.
diff --git a/unzip/distinfo b/unzip/distinfo
index 1abce3930b..ecb6642f42 100644
--- a/unzip/distinfo
+++ b/unzip/distinfo
@@ -1,6 +1,15 @@
-$NetBSD: distinfo,v 1.1 2013/05/31 13:41:37 thomasklausner Exp $
+$NetBSD: distinfo,v 1.37 2025/07/03 09:59:10 jperkin Exp $
 
-RMD160 (unzip610b.zip) = a8e0df8e07240f5e782012004a64a2ca4f5db109
-Size (unzip610b.zip) = 1648945 bytes
-SHA1 (patch-aa) = d0bbfd14cae937f5c4170780dfcd1d46cc10d790
-SHA1 (patch-ab) = 7c5c31df628ca8bcd80a12c821a0c501607cbf5e
+BLAKE2s (unzip60.tgz) = d083b60907af71a6870edc1e87be4566dee486d5089e1fc3b57cc6ebac00818f
+SHA512 (unzip60.tgz) = 0694e403ebc57b37218e00ec1a406cae5cc9c5b52b6798e0d4590840b6cdbf9ddc0d9471f67af783e960f8fa2e620394d51384257dca23d06bcd90224a80ce5d
+Size (unzip60.tgz) = 1376845 bytes
+SHA1 (patch-ab) = 672635c469e0a53ac9808f8155ee38643a8acf69
+SHA1 (patch-ac) = 27b91401d4d5ecc3842c91dc49c08f42c8646154
+SHA1 (patch-crypt.c) = e44e14ba2c8e5651659c6756a5adbe88b4385ca4
+SHA1 (patch-extract.c) = 042fe7d233d0b3cb1e978902c901e8239f7a3732
+SHA1 (patch-fileio.c) = ef87b5e8a60b9268e4b0439766d089130b322d86
+SHA1 (patch-globals.h) = d537ad18fa4406cd4b78ccee694c3cccb832f5a3
+SHA1 (patch-list.c) = 29e6dc3f5d40bb087a8bff58f75eb02568f3ad87
+SHA1 (patch-process.c) = a9c95ada1a0d3ac706d97a0bbd7dd99220f1fe69
+SHA1 (patch-unix_unxcfg.h) = 8128ea53719ca88e9a4f4788fb7b4f706399f8ae
+SHA1 (patch-zipinfo.c) = 0d93fd9b145e7e707762119ee30ddf8eac9c2f31
diff --git a/unzip/patches/patch-aa b/unzip/patches/patch-aa
deleted file mode 100644
index cb3472621f..0000000000
--- a/unzip/patches/patch-aa
+++ /dev/null
@@ -1,23 +0,0 @@
-$NetBSD: patch-aa,v 1.1 2013/05/31 13:41:37 thomasklausner Exp $
-
-More compatible to different versions of zlib.h files.
-
---- unzip.h.orig	2004-05-22 20:04:23.000000000 -0500
-+++ unzip.h
-@@ -258,11 +258,16 @@ freely, subject to the following restric
- #endif
- 
- /* used to remove arguments in function prototypes for non-ANSI C */
-+#ifdef USE_ZLIB
-+#include <zconf.h>
-+#endif
-+#ifndef OF
- #ifdef PROTO
- #  define OF(a) a
- #else
- #  define OF(a) ()
- #endif
-+#endif
- 
- /* enable the "const" keyword only if MODERN and if not otherwise instructed */
- #ifdef MODERN
diff --git a/unzip/patches/patch-ab b/unzip/patches/patch-ab
index fe105f4c96..dbd0e38fe9 100644
--- a/unzip/patches/patch-ab
+++ b/unzip/patches/patch-ab
@@ -1,19 +1,19 @@
-$NetBSD: patch-ab,v 1.1 2013/05/31 13:41:37 thomasklausner Exp $
+$NetBSD: patch-ab,v 1.7 2012/04/25 19:35:02 wiz Exp $
 
 pkgsrc adaptation.
 
---- unix/Makefile.orig	2010-07-30 23:39:00.000000000 +0000
+--- unix/Makefile.orig	2009-01-18 22:41:18.000000000 +0000
 +++ unix/Makefile
-@@ -56,7 +56,7 @@
- # flags, such as -DDOSWILD).
+@@ -42,7 +42,7 @@
+ # such as -DDOSWILD).
  
  # UnZip flags
 -CC = cc#	try using "gcc" target rather than changing this (CC and LD
 +#CC = cc#	try using "gcc" target rather than changing this (CC and LD
  LD = $(CC)#	must match, else "unresolved symbol:  ___main" is possible)
  AS = as
- LOC = $(D_USE_BZ2) $(D_USE_ZLIB) $(LOCAL_UNZIP)
-@@ -598,7 +598,7 @@ generic_bz2:	unix_make
+ LOC = $(D_USE_BZ2) $(LOCAL_UNZIP)
+@@ -580,7 +580,7 @@ generic_bz2:	unix_make
  generic_zlib:	unix_make
  	@echo\
   "This target assumes zlib (libz.a or libz.so.*) is already installed."
@@ -22,7 +22,7 @@ pkgsrc adaptation.
  
  # Generic GNU C shared library.  This is an example of how to compile UnZip as
  # a shared library.  (Doing so as a static library would be similar.)  See also
-@@ -669,7 +669,7 @@ vax:		unzips	# general-purpose VAX targe
+@@ -651,7 +651,7 @@ vax:		unzips	# general-purpose VAX targe
  bsd:		_bsd	# generic BSD (BSD 4.2 & Ultrix handled in unzip.h)
  
  _bsd:		unix_make
diff --git a/unzip/patches/patch-ac b/unzip/patches/patch-ac
new file mode 100644
index 0000000000..16fd05a80b
--- /dev/null
+++ b/unzip/patches/patch-ac
@@ -0,0 +1,30 @@
+$NetBSD: patch-ac,v 1.3 2012/09/14 13:10:48 wiz Exp $
+
+Fix build with -DFUNZIP.
+
+--- inflate.c.orig	2008-07-30 01:31:08.000000000 +0000
++++ inflate.c
+@@ -473,7 +473,11 @@ int UZinflate(__G__ is_defl64)
+                     retval = 2;
+                 } else {
+                     /* output write failure */
++#ifdef FUNZIP
++                    retval = PK_DISK;
++#else
+                     retval = (G.disk_full != 0 ? PK_DISK : IZ_CTRLC);
++#endif
+                 }
+             } else {
+                 Trace((stderr, "oops!  (inflateBack9() err = %d)\n", err));
+@@ -538,7 +542,11 @@ int UZinflate(__G__ is_defl64)
+                     retval = 2;
+                 } else {
+                     /* output write failure */
++#ifdef FUNZIP
++                    retval = PK_DISK;
++#else
+                     retval = (G.disk_full != 0 ? PK_DISK : IZ_CTRLC);
++#endif
+                 }
+             } else {
+                 Trace((stderr, "oops!  (inflateBack() err = %d)\n", err));
diff --git a/unzip/patches/patch-crypt.c b/unzip/patches/patch-crypt.c
new file mode 100644
index 0000000000..a4cfedd8f5
--- /dev/null
+++ b/unzip/patches/patch-crypt.c
@@ -0,0 +1,26 @@
+$NetBSD: patch-crypt.c,v 1.1 2015/11/11 12:47:27 wiz Exp $
+
+Bug fix for heap overflow, from Debian.
+CVE-2015-7696
+
+--- crypt.c.orig	2007-01-05 15:47:36.000000000 +0000
++++ crypt.c
+@@ -465,7 +465,17 @@ int decrypt(__G__ passwrd)
+     GLOBAL(pInfo->encrypted) = FALSE;
+     defer_leftover_input(__G);
+     for (n = 0; n < RAND_HEAD_LEN; n++) {
+-        b = NEXTBYTE;
++        /* 2012-11-23 SMS.  (OUSPG report.)
++         * Quit early if compressed size < HEAD_LEN.  The resulting
++         * error message ("unable to get password") could be improved,
++         * but it's better than trying to read nonexistent data, and
++         * then continuing with a negative G.csize.  (See
++         * fileio.c:readbyte()).
++         */
++        if ((b = NEXTBYTE) == (ush)EOF)
++        {
++            return PK_ERR;
++        }
+         h[n] = (uch)b;
+         Trace((stdout, " (%02x)", h[n]));
+     }
diff --git a/unzip/patches/patch-extract.c b/unzip/patches/patch-extract.c
new file mode 100644
index 0000000000..ce15a9ba96
--- /dev/null
+++ b/unzip/patches/patch-extract.c
@@ -0,0 +1,123 @@
+$NetBSD: patch-extract.c,v 1.3 2015/11/11 12:47:27 wiz Exp $
+
+Fixes for
+* https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2014-8139
+* https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2014-8140
+* http://sf.net/projects/mancha/files/sec/unzip-6.0_overflow2.diff via
+  http://seclists.org/oss-sec/2014/q4/1131 and
+  http://seclists.org/oss-sec/2014/q4/507 and later version
+  http://sf.net/projects/mancha/files/sec/unzip-6.0_overflow3.diff via
+  http://www.openwall.com/lists/oss-security/2015/02/11/7
+
+By carefully crafting a corrupt ZIP archive with "extra fields" that
+purport to have compressed blocks larger than the corresponding
+uncompressed blocks in STORED no-compression mode, an attacker can
+trigger a heap overflow that can result in application crash or
+possibly have other unspecified impact.
+
+This patch ensures that when extra fields use STORED mode, the
+"compressed" and uncompressed block sizes match.
+* CVE-2015-7697 (from Debian)
+  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=802160
+* integer underflow
+  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=802160
+
+--- extract.c.orig	2009-03-14 01:32:52.000000000 +0000
++++ extract.c
+@@ -1,5 +1,5 @@
+ /*
+-  Copyright (c) 1990-2009 Info-ZIP.  All rights reserved.
++  Copyright (c) 1990-2014 Info-ZIP.  All rights reserved.
+ 
+   See the accompanying file LICENSE, version 2009-Jan-02 or later
+   (the contents of which are also included in unzip.h) for terms of use.
+@@ -298,6 +298,8 @@ char ZCONST Far TruncNTSD[] =
+ #ifndef SFX
+    static ZCONST char Far InconsistEFlength[] = "bad extra-field entry:\n \
+      EF block length (%u bytes) exceeds remaining EF data (%u bytes)\n";
++   static ZCONST char Far TooSmallEFlength[] = "bad extra-field entry:\n \
++     EF block length (%u bytes) invalid (< %d)\n";
+    static ZCONST char Far InvalidComprDataEAs[] =
+      " invalid compressed data for EAs\n";
+ #  if (defined(WIN32) && defined(NTSD_EAS))
+@@ -1255,8 +1257,17 @@ static int extract_or_test_entrylist(__G
+         if (G.lrec.compression_method == STORED) {
+             zusz_t csiz_decrypted = G.lrec.csize;
+ 
+-            if (G.pInfo->encrypted)
++            if (G.pInfo->encrypted) {
++                if (csiz_decrypted <= 12) {
++                    /* handle the error now to prevent unsigned overflow */
++                    Info(slide, 0x401, ((char *)slide,
++                      LoadFarStringSmall(ErrUnzipNoFile),
++                      LoadFarString(InvalidComprData),
++                      LoadFarStringSmall2(Inflate)));
++                    return PK_ERR;
++                }
+                 csiz_decrypted -= 12;
++            }
+             if (G.lrec.ucsize != csiz_decrypted) {
+                 Info(slide, 0x401, ((char *)slide,
+                   LoadFarStringSmall2(WrnStorUCSizCSizDiff),
+@@ -2023,7 +2034,8 @@ static int TestExtraField(__G__ ef, ef_l
+         ebID = makeword(ef);
+         ebLen = (unsigned)makeword(ef+EB_LEN);
+ 
+-        if (ebLen > (ef_len - EB_HEADSIZE)) {
++        if (ebLen > (ef_len - EB_HEADSIZE))
++        {
+            /* Discovered some extra field inconsistency! */
+             if (uO.qflag)
+                 Info(slide, 1, ((char *)slide, "%-22s ",
+@@ -2032,6 +2044,16 @@ static int TestExtraField(__G__ ef, ef_l
+               ebLen, (ef_len - EB_HEADSIZE)));
+             return PK_ERR;
+         }
++        else if (ebLen < EB_HEADSIZE)
++        {
++            /* Extra block length smaller than header length. */
++            if (uO.qflag)
++                Info(slide, 1, ((char *)slide, "%-22s ",
++                  FnFilter1(G.filename)));
++            Info(slide, 1, ((char *)slide, LoadFarString(TooSmallEFlength),
++              ebLen, EB_HEADSIZE));
++            return PK_ERR;
++        }
+ 
+         switch (ebID) {
+             case EF_OS2:
+@@ -2217,6 +2239,7 @@ static int test_compr_eb(__G__ eb, eb_si
+     ulg eb_ucsize;
+     uch *eb_ucptr;
+     int r;
++    ush method;
+ 
+     if (compr_offset < 4)                /* field is not compressed: */
+         return PK_OK;                    /* do nothing and signal OK */
+@@ -2226,6 +2249,13 @@ static int test_compr_eb(__G__ eb, eb_si
+          eb_size <= (compr_offset + EB_CMPRHEADLEN)))
+         return IZ_EF_TRUNC;               /* no compressed data! */
+ 
++    method = makeword(eb + (EB_HEADSIZE + compr_offset));
++    if ((method == STORED) &&
++        (eb_size - compr_offset - EB_CMPRHEADLEN != eb_ucsize))
++	return PK_ERR;			  /* compressed & uncompressed
++					   * should match in STORED
++					   * method */
++
+     if (
+ #ifdef INT_16BIT
+         (((ulg)(extent)eb_ucsize) != eb_ucsize) ||
+@@ -2701,6 +2731,12 @@ __GDEF
+     int repeated_buf_err;
+     bz_stream bstrm;
+ 
++    if (G.incnt <= 0 && G.csize <= 0L) {
++        /* avoid an infinite loop */
++        Trace((stderr, "UZbunzip2() got empty input\n"));
++        return 2;
++    }
++
+ #if (defined(DLL) && !defined(NO_SLIDE_REDIR))
+     if (G.redirect_slide)
+         wsize = G.redirect_size, redirSlide = G.redirect_buffer;
diff --git a/unzip/patches/patch-fileio.c b/unzip/patches/patch-fileio.c
new file mode 100644
index 0000000000..2d15e8dbbc
--- /dev/null
+++ b/unzip/patches/patch-fileio.c
@@ -0,0 +1,77 @@
+$NetBSD: patch-fileio.c,v 1.2 2024/08/06 14:40:13 nia Exp $
+
+https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2014-8141
+https://sources.debian.org/patches/unzip/6.0-28/28-cve-2022-0529-and-cve-2022-0530.patch/
+
+--- fileio.c.orig	2009-04-20 00:03:44.000000000 +0000
++++ fileio.c
+@@ -171,11 +171,15 @@ static ZCONST char Far ReadError[] = "er
+ static ZCONST char Far FilenameTooLongTrunc[] =
+   "warning:  filename too long--truncating.\n";
+ #ifdef UNICODE_SUPPORT
++   static ZCONST char Far UFilenameCorrupt[] =
++     "error: Unicode filename corrupt.\n";
+    static ZCONST char Far UFilenameTooLongTrunc[] =
+-     "warning:  Converted unicode filename too long--truncating.\n";
++     "warning:  Converted Unicode filename too long--truncating.\n";
+ #endif
+ static ZCONST char Far ExtraFieldTooLong[] =
+   "warning:  extra field too long (%d).  Ignoring...\n";
++static ZCONST char Far ExtraFieldCorrupt[] =
++  "warning:  extra field (type: 0x%04x) corrupt.  Continuing...\n";
+ 
+ #ifdef WINDLL
+    static ZCONST char Far DiskFullQuery[] =
+@@ -2295,7 +2299,12 @@ int do_string(__G__ length, option)   /*
+             if (readbuf(__G__ (char *)G.extra_field, length) == 0)
+                 return PK_EOF;
+             /* Looks like here is where extra fields are read */
+-            getZip64Data(__G__ G.extra_field, length);
++            if (getZip64Data(__G__ G.extra_field, length) != PK_COOL)
++            {
++                Info(slide, 0x401, ((char *)slide,
++                 LoadFarString( ExtraFieldCorrupt), EF_PKSZ64));
++                error = PK_WARN;
++            }
+ #ifdef UNICODE_SUPPORT
+             G.unipath_filename = NULL;
+             if (G.UzO.U_flag < 2) {
+@@ -2340,16 +2349,30 @@ int do_string(__G__ length, option)   /*
+                   /* convert UTF-8 to local character set */
+                   fn = utf8_to_local_string(G.unipath_filename,
+                                             G.unicode_escape_all);
+-                  /* make sure filename is short enough */
+-                  if (strlen(fn) >= FILNAMSIZ) {
+-                    fn[FILNAMSIZ - 1] = '\0';
++
++                  /* 2022-07-22 SMS, et al.  CVE-2022-0530
++                   * Detect conversion failure, emit message.
++                   * Continue with unconverted name.
++                   */
++                  if (fn == NULL)
++                  {
+                     Info(slide, 0x401, ((char *)slide,
+-                      LoadFarString(UFilenameTooLongTrunc)));
+-                    error = PK_WARN;
++                     LoadFarString(UFilenameCorrupt)));
++                    error = PK_ERR;
++                  }
++                  else
++                  {
++                    /* make sure filename is short enough */
++                    if (strlen(fn) >= FILNAMSIZ) {
++                      fn[FILNAMSIZ - 1] = '\0';
++                      Info(slide, 0x401, ((char *)slide,
++                        LoadFarString(UFilenameTooLongTrunc)));
++                      error = PK_WARN;
++                    }
++                    /* replace filename with converted UTF-8 */
++                    strcpy(G.filename, fn);
++                    free(fn);
+                   }
+-                  /* replace filename with converted UTF-8 */
+-                  strcpy(G.filename, fn);
+-                  free(fn);
+                 }
+ # endif /* UNICODE_WCHAR */
+                 if (G.unipath_filename != G.filename_full)
diff --git a/unzip/patches/patch-globals.h b/unzip/patches/patch-globals.h
new file mode 100644
index 0000000000..0eb9a7eee3
--- /dev/null
+++ b/unzip/patches/patch-globals.h
@@ -0,0 +1,21 @@
+$NetBSD: patch-globals.h,v 1.1 2024/08/05 09:03:00 tnn Exp $
+
+Match return type of get_crc_table() from zlib.h.
+Without it we get an error with GCC 14.
+This looks somewhat sketchy but make test succeeds,
+and 32-bit is the correct width for the crc32 table, so ...
+
+extract.c:363:25: error: assignment to 'const ulg *' {aka 'const long unsigned int *'} from incompatible pointer type 'const z_crc_t *' {aka 'const unsigned int *'} [-Wincompatible-pointer-types]
+363 |         if ((CRC_32_TAB = get_crc_table()) == NULL) {
+
+--- globals.h.orig	2024-08-05 10:40:15.418511764 +0000
++++ globals.h
+@@ -226,7 +226,7 @@ typedef struct Globals {
+ #if (!defined(USE_ZLIB) || defined(USE_OWN_CRCTAB))
+     ZCONST ulg near *crc_32_tab;
+ #else
+-    ZCONST ulg Far *crc_32_tab;
++    ZCONST z_crc_t Far *crc_32_tab;
+ #endif
+     ulg       crc32val;             /* CRC shift reg. (was static in funzip) */
+ 
diff --git a/unzip/patches/patch-list.c b/unzip/patches/patch-list.c
new file mode 100644
index 0000000000..e0961ec9f1
--- /dev/null
+++ b/unzip/patches/patch-list.c
@@ -0,0 +1,54 @@
+$NetBSD: patch-list.c,v 1.3 2019/07/15 14:08:03 nia Exp $
+
+chunk 1:
+CVE-2018-18384 fix from
+https://sourceforge.net/p/infozip/bugs/53/
+and
+https://sources.debian.org/patches/unzip/6.0-24/07-increase-size-of-cfactorstr.patch/
+
+chunk 2:
+Big-hammer fix for
+http://seclists.org/oss-sec/2014/q4/497
+
+chunk 3:
+CVE-2014-9913 fix from
+https://people.debian.org/~sanvila/unzip/cve-2014-9913/cve-2014-9913-unzip-buffer-overflow.txt
+via
+http://www.info-zip.org/phpBB3/viewtopic.php?f=7&t=529
+
+--- list.c.orig	2009-02-08 17:11:34.000000000 +0000
++++ list.c
+@@ -97,7 +97,7 @@ int list_files(__G)    /* return PK-type
+ {
+     int do_this_file=FALSE, cfactor, error, error_in_archive=PK_COOL;
+ #ifndef WINDLL
+-    char sgn, cfactorstr[10];
++    char sgn, cfactorstr[12];
+     int longhdr=(uO.vflag>1);
+ #endif
+     int date_format;
+@@ -116,7 +116,7 @@ int list_files(__G)    /* return PK-type
+     ulg acl_size, tot_aclsize=0L, tot_aclfiles=0L;
+ #endif
+     min_info info;
+-    char methbuf[8];
++    char methbuf[80];
+     static ZCONST char dtype[]="NXFS";  /* see zi_short() */
+     static ZCONST char Far method[NUM_METHODS+1][8] =
+         {"Stored", "Shrunk", "Reduce1", "Reduce2", "Reduce3", "Reduce4",
+@@ -339,7 +339,14 @@ int list_files(__G)    /* return PK-type
+                 G.crec.compression_method == ENHDEFLATED) {
+                 methbuf[5] = dtype[(G.crec.general_purpose_bit_flag>>1) & 3];
+             } else if (methnum >= NUM_METHODS) {
+-                sprintf(&methbuf[4], "%03u", G.crec.compression_method);
++                /* Fix for CVE-2014-9913, similar to CVE-2016-9844.
++                 * Use the old decimal format only for values which fit.
++                 */
++                if (G.crec.compression_method <= 999) {
++                    sprintf( &methbuf[ 4], "%03u", G.crec.compression_method);
++                } else {
++                    sprintf( &methbuf[ 3], "%04X", G.crec.compression_method);
++                }
+             }
+ 
+ #if 0       /* GRR/Euro:  add this? */
diff --git a/unzip/patches/patch-process.c b/unzip/patches/patch-process.c
new file mode 100644
index 0000000000..5e139ce58d
--- /dev/null
+++ b/unzip/patches/patch-process.c
@@ -0,0 +1,206 @@
+$NetBSD: patch-process.c,v 1.2 2024/08/06 14:40:13 nia Exp $
+
+https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2014-8141
+https://sources.debian.org/patches/unzip/6.0-28/28-cve-2022-0529-and-cve-2022-0530.patch/
+
+--- process.c.orig	2009-03-06 01:25:10.000000000 +0000
++++ process.c
+@@ -1,5 +1,5 @@
+ /*
+-  Copyright (c) 1990-2009 Info-ZIP.  All rights reserved.
++  Copyright (c) 1990-2014 Info-ZIP.  All rights reserved.
+ 
+   See the accompanying file LICENSE, version 2009-Jan-02 or later
+   (the contents of which are also included in unzip.h) for terms of use.
+@@ -222,6 +222,8 @@ static ZCONST char Far ZipfileCommTrunc1
+      "\nwarning:  Unicode Path version > 1\n";
+    static ZCONST char Far UnicodeMismatchError[] =
+      "\nwarning:  Unicode Path checksum invalid\n";
++   static ZCONST char Far UFilenameTooLongTrunc[] =
++     "warning:  filename too long (P1) -- truncating.\n";
+ #endif
+ 
+ 
+@@ -1888,48 +1890,83 @@ int getZip64Data(__G__ ef_buf, ef_len)
+     and a 4-byte version of disk start number.
+     Sets both local header and central header fields.  Not terribly clever,
+     but it means that this procedure is only called in one place.
++
++    2014-12-05 SMS.  (oCERT.org report.)  CVE-2014-8141.
++    Added checks to ensure that enough data are available before calling
++    makeint64() or makelong().  Replaced various sizeof() values with
++    simple ("4" or "8") constants.  (The Zip64 structures do not depend
++    on our variable sizes.)  Error handling is crude, but we should now
++    stay within the buffer.
+   ---------------------------------------------------------------------------*/
+ 
++#define Z64FLGS 0xffff
++#define Z64FLGL 0xffffffff
++
+     if (ef_len == 0 || ef_buf == NULL)
+         return PK_COOL;
+ 
+     Trace((stderr,"\ngetZip64Data: scanning extra field of length %u\n",
+       ef_len));
+ 
+-    while (ef_len >= EB_HEADSIZE) {
++    while (ef_len >= EB_HEADSIZE)
++    {
+         eb_id = makeword(EB_ID + ef_buf);
+         eb_len = makeword(EB_LEN + ef_buf);
+ 
+-        if (eb_len > (ef_len - EB_HEADSIZE)) {
+-            /* discovered some extra field inconsistency! */
++        if (eb_len > (ef_len - EB_HEADSIZE))
++        {
++            /* Extra block length exceeds remaining extra field length. */
+             Trace((stderr,
+               "getZip64Data: block length %u > rest ef_size %u\n", eb_len,
+               ef_len - EB_HEADSIZE));
+             break;
+         }
+-        if (eb_id == EF_PKSZ64) {
+ 
+-          int offset = EB_HEADSIZE;
++        if (eb_id == EF_PKSZ64)
++        {
++          unsigned offset = EB_HEADSIZE;
++
++          if ((G.crec.ucsize == Z64FLGL) || (G.lrec.ucsize == Z64FLGL))
++          {
++            if (offset+ 8 > ef_len)
++              return PK_ERR;
+ 
+-          if (G.crec.ucsize == 0xffffffff || G.lrec.ucsize == 0xffffffff){
+-            G.lrec.ucsize = G.crec.ucsize = makeint64(offset + ef_buf);
+-            offset += sizeof(G.crec.ucsize);
++            G.crec.ucsize = G.lrec.ucsize = makeint64(offset + ef_buf);
++            offset += 8;
+           }
+-          if (G.crec.csize == 0xffffffff || G.lrec.csize == 0xffffffff){
+-            G.csize = G.lrec.csize = G.crec.csize = makeint64(offset + ef_buf);
+-            offset += sizeof(G.crec.csize);
++
++          if ((G.crec.csize == Z64FLGL) || (G.lrec.csize == Z64FLGL))
++          {
++            if (offset+ 8 > ef_len)
++              return PK_ERR;
++
++            G.csize = G.crec.csize = G.lrec.csize = makeint64(offset + ef_buf);
++            offset += 8;
+           }
+-          if (G.crec.relative_offset_local_header == 0xffffffff){
++
++          if (G.crec.relative_offset_local_header == Z64FLGL)
++          {
++            if (offset+ 8 > ef_len)
++              return PK_ERR;
++
+             G.crec.relative_offset_local_header = makeint64(offset + ef_buf);
+-            offset += sizeof(G.crec.relative_offset_local_header);
++            offset += 8;
+           }
+-          if (G.crec.disk_number_start == 0xffff){
++
++          if (G.crec.disk_number_start == Z64FLGS)
++          {
++            if (offset+ 4 > ef_len)
++              return PK_ERR;
++
+             G.crec.disk_number_start = (zuvl_t)makelong(offset + ef_buf);
+-            offset += sizeof(G.crec.disk_number_start);
++            offset += 4;
+           }
++#if 0
++          break;                /* Expect only one EF_PKSZ64 block. */
++#endif /* 0 */
+         }
+ 
+-        /* Skip this extra field block */
++        /* Skip this extra field block. */
+         ef_buf += (eb_len + EB_HEADSIZE);
+         ef_len -= (eb_len + EB_HEADSIZE);
+     }
+@@ -1984,7 +2021,7 @@ int getUnicodeData(__G__ ef_buf, ef_len)
+         }
+         if (eb_id == EF_UNIPATH) {
+ 
+-          int offset = EB_HEADSIZE;
++          unsigned offset = EB_HEADSIZE;
+           ush ULen = eb_len - 5;
+           ulg chksum = CRCVAL_INITIAL;
+ 
+@@ -2440,16 +2477,17 @@ char *wide_to_local_string(wide_string, 
+   int state_dependent;
+   int wsize = 0;
+   int max_bytes = MB_CUR_MAX;
+-  char buf[9];
++  char buf[ MB_CUR_MAX+ 1];             /* ("+1" not really needed?) */
+   char *buffer = NULL;
+   char *local_string = NULL;
++  size_t buffer_size;                   /* CVE-2022-0529 */
+ 
+   for (wsize = 0; wide_string[wsize]; wsize++) ;
+ 
+   if (max_bytes < MAX_ESCAPE_BYTES)
+     max_bytes = MAX_ESCAPE_BYTES;
+-
+-  if ((buffer = (char *)malloc(wsize * max_bytes + 1)) == NULL) {
++  buffer_size = wsize * max_bytes + 1;          /* Reused below. */
++  if ((buffer = (char *)malloc( buffer_size)) == NULL) {
+     return NULL;
+   }
+ 
+@@ -2487,8 +2525,28 @@ char *wide_to_local_string(wide_string, 
+     } else {
+       /* no MB for this wide */
+         /* use escape for wide character */
+-        char *escape_string = wide_to_escape_string(wide_string[i]);
+-        strcat(buffer, escape_string);
++        size_t buffer_len;
++        size_t escape_string_len;
++        char *escape_string;
++        int err_msg = 0;
++
++        escape_string = wide_to_escape_string(wide_string[i]);
++        buffer_len = strlen( buffer);
++        escape_string_len = strlen( escape_string);
++
++        /* Append escape string, as space allows. */
++        /* 2022-07-18 SMS, et al.  CVE-2022-0529 */
++        if (escape_string_len > buffer_size- buffer_len- 1)
++        {
++            escape_string_len = buffer_size- buffer_len- 1;
++            if (err_msg == 0)
++            {
++                err_msg = 1;
++                Info(slide, 0x401, ((char *)slide,
++                 LoadFarString( UFilenameTooLongTrunc)));
++            }
++        }
++        strncat( buffer, escape_string, escape_string_len);
+         free(escape_string);
+     }
+   }
+@@ -2540,9 +2598,18 @@ char *utf8_to_local_string(utf8_string, 
+   ZCONST char *utf8_string;
+   int escape_all;
+ {
+-  zwchar *wide = utf8_to_wide_string(utf8_string);
+-  char *loc = wide_to_local_string(wide, escape_all);
+-  free(wide);
++  zwchar *wide;
++  char *loc = NULL;
++
++  wide = utf8_to_wide_string( utf8_string);
++
++  /* 2022-07-25 SMS, et al.  CVE-2022-0530 */
++  if (wide != NULL)
++  {
++    loc = wide_to_local_string( wide, escape_all);
++    free( wide);
++  }
++
+   return loc;
+ }
+ 
diff --git a/unzip/patches/patch-unix_unxcfg.h b/unzip/patches/patch-unix_unxcfg.h
new file mode 100644
index 0000000000..adbac7d5d4
--- /dev/null
+++ b/unzip/patches/patch-unix_unxcfg.h
@@ -0,0 +1,48 @@
+$NetBSD: patch-unix_unxcfg.h,v 1.4 2025/07/03 09:59:10 jperkin Exp $
+
+* Fix build on Debian GNU/kFreeBSD.
+* Fix build under OpenBSD 5.5
+  Patch from OpenBSD Ports
+  "timeb was already well deprecated on 4.4BSD"
+* Remove K&R prototype for gmtime()
+
+--- unix/unxcfg.h.orig	2009-04-16 18:36:12.000000000 +0000
++++ unix/unxcfg.h
+@@ -52,6 +52,7 @@
+ 
+ #include <sys/types.h>          /* off_t, time_t, dev_t, ... */
+ #include <sys/stat.h>
++#include <unistd.h>
+ 
+ #ifdef NO_OFF_T
+   typedef long zoff_t;
+@@ -111,16 +112,17 @@ typedef struct stat z_stat;
+ 
+ #ifdef BSD
+ #  include <sys/time.h>
+-#  include <sys/timeb.h>
++#  ifndef BSD4_4
++#    include <sys/timeb.h>
++#  endif
+ #  if (defined(_AIX) || defined(__GLIBC__) || defined(__GNU__))
+ #    include <time.h>
+ #  endif
+ #else
+ #  include <time.h>
+-   struct tm *gmtime(), *localtime();
+ #endif
+ 
+-#if (defined(BSD4_4) || (defined(SYSV) && defined(MODERN)))
++#if (defined(BSD4_4) || defined(__illumos__) || (defined(SYSV) && defined(MODERN)))
+ #  include <unistd.h>           /* this includes utime.h on SGIs */
+ #  if (defined(BSD4_4) || defined(linux) || defined(__GLIBC__))
+ #    include <utime.h>
+@@ -130,7 +132,7 @@ typedef struct stat z_stat;
+ #    include <utime.h>
+ #    define GOT_UTIMBUF
+ #  endif
+-#  if (!defined(GOT_UTIMBUF) && defined(__GNU__))
++#  if (!defined(GOT_UTIMBUF) && (defined(__GNU__) || defined(__illumos__)))
+ #    include <utime.h>
+ #    define GOT_UTIMBUF
+ #  endif
diff --git a/unzip/patches/patch-zipinfo.c b/unzip/patches/patch-zipinfo.c
new file mode 100644
index 0000000000..0110ba0f99
--- /dev/null
+++ b/unzip/patches/patch-zipinfo.c
@@ -0,0 +1,27 @@
+$NetBSD: patch-zipinfo.c,v 1.1 2017/02/04 23:25:59 wiz Exp $
+
+Fix crash in zipinfo, CVE-2016-9844.
+http://www.openwall.com/lists/oss-security/2016/12/05/19
+
+--- zipinfo.c.orig	2009-02-08 17:04:30.000000000 +0000
++++ zipinfo.c
+@@ -1921,7 +1921,18 @@ static int zi_short(__G)   /* return PK-
+         ush  dnum=(ush)((G.crec.general_purpose_bit_flag>>1) & 3);
+         methbuf[3] = dtype[dnum];
+     } else if (methnum >= NUM_METHODS) {   /* unknown */
+-        sprintf(&methbuf[1], "%03u", G.crec.compression_method);
++        /* 2016-12-05 SMS.
++         * https://launchpad.net/bugs/1643750
++         * Unexpectedly large compression methods overflow
++         * &methbuf[].  Use the old, three-digit decimal format
++         * for values which fit.  Otherwise, sacrifice the "u",
++         * and use four-digit hexadecimal.
++         */
++        if (G.crec.compression_method <= 999) {
++            sprintf( &methbuf[ 1], "%03u", G.crec.compression_method);
++        } else {
++            sprintf( &methbuf[ 0], "%04X", G.crec.compression_method);
++        }
+     }
+ 
+     for (k = 0;  k < 15;  ++k)


Home | Main Index | Thread Index | Old Index