[Midnightbsd-cvs] mports [19507] trunk/archivers/unzip: patch the extract code to fix some edge cases
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Jun 21 15:21:24 EDT 2015
Revision: 19507
http://svnweb.midnightbsd.org/mports/?rev=19507
Author: laffer1
Date: 2015-06-21 15:21:23 -0400 (Sun, 21 Jun 2015)
Log Message:
-----------
patch the extract code to fix some edge cases
Modified Paths:
--------------
trunk/archivers/unzip/Makefile
trunk/archivers/unzip/files/extra-iconv-patch-unix_unix.c
Added Paths:
-----------
trunk/archivers/unzip/files/patch-extract.c
Modified: trunk/archivers/unzip/Makefile
===================================================================
--- trunk/archivers/unzip/Makefile 2015-06-21 15:32:42 UTC (rev 19506)
+++ trunk/archivers/unzip/Makefile 2015-06-21 19:21:23 UTC (rev 19507)
@@ -2,7 +2,7 @@
PORTNAME= unzip
PORTVERSION= 6.0
-PORTREVISION= 2
+PORTREVISION= 3
CATEGORIES= archivers
MASTER_SITES= SF/infozip/UnZip%206.x%20%28latest%29/UnZip%20${PORTVERSION}/:main \
SF/infozip/UnZip%205.x%20and%20earlier/5.51/:unreduce
Modified: trunk/archivers/unzip/files/extra-iconv-patch-unix_unix.c
===================================================================
--- trunk/archivers/unzip/files/extra-iconv-patch-unix_unix.c 2015-06-21 15:32:42 UTC (rev 19506)
+++ trunk/archivers/unzip/files/extra-iconv-patch-unix_unix.c 2015-06-21 19:21:23 UTC (rev 19507)
@@ -1,5 +1,5 @@
---- unix/unix.c.orig 2009-01-23 23:31:26 UTC
-+++ unix/unix.c
+--- unix/unix.c.orig 2015-02-17 15:18:36.176142072 -0800
++++ unix/unix.c 2015-02-17 15:18:56.289341100 -0800
@@ -30,6 +30,9 @@
#define UNZIP_INTERNAL
#include "unzip.h"
@@ -10,7 +10,7 @@
#ifdef SCO_XENIX
# define SYSNDIR
#else /* SCO Unix, AIX, DNIX, TI SysV, Coherent 4.x, ... */
-@@ -1874,3 +1877,90 @@ static void qlfix(__G__ ef_ptr, ef_len)
+@@ -1874,3 +1877,102 @@
}
}
#endif /* QLZIP */
@@ -76,15 +76,27 @@
+
+ slen = strlen(string);
+ s = string;
-+ dlen = buflen = 2*slen;
-+ d = buf = malloc(buflen + 1);
++
++ /* Make sure OUTBUFSIZ + 1 never ends up smaller than FILNAMSIZ
++ * as this function also gets called with G.outbuf in fileio.c
++ */
++ buflen = FILNAMSIZ;
++ if (OUTBUFSIZ + 1 < FILNAMSIZ)
++ {
++ buflen = OUTBUFSIZ + 1;
++ }
++
++ d = buf = malloc(buflen);
+ if(!d)
+ goto cleanup;
++
+ bzero(buf,buflen);
++ dlen = buflen - 1;
++
+ if(iconv(cd, &s, &slen, &d, &dlen) == (size_t)-1)
+ goto cleanup;
+ strncpy(string, buf, buflen);
-+
++
+ cleanup:
+ free(buf);
+ iconv_close(cd);
Added: trunk/archivers/unzip/files/patch-extract.c
===================================================================
--- trunk/archivers/unzip/files/patch-extract.c (rev 0)
+++ trunk/archivers/unzip/files/patch-extract.c 2015-06-21 19:21:23 UTC (rev 19507)
@@ -0,0 +1,77 @@
+--- extract.c.orig 2009-03-14 01:32:52 UTC
++++ 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))
+@@ -2023,7 +2025,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 +2035,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,14 +2230,28 @@ 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 */
+
++ /* Return no/bad-data error status if any problem is found:
++ * 1. eb_size is too small to hold the uncompressed size
++ * (eb_ucsize). (Else extract eb_ucsize.)
++ * 2. eb_ucsize is zero (invalid). 2014-12-04 SMS.
++ * 3. eb_ucsize is positive, but eb_size is too small to hold
++ * the compressed data header.
++ */
+ if ((eb_size < (EB_UCSIZE_P + 4)) ||
+- ((eb_ucsize = makelong(eb+(EB_HEADSIZE+EB_UCSIZE_P))) > 0L &&
+- eb_size <= (compr_offset + EB_CMPRHEADLEN)))
+- return IZ_EF_TRUNC; /* no compressed data! */
++ ((eb_ucsize = makelong( eb+ (EB_HEADSIZE+ EB_UCSIZE_P))) == 0L) ||
++ ((eb_ucsize > 0L) && (eb_size <= (compr_offset + EB_CMPRHEADLEN))))
++ return IZ_EF_TRUNC; /* no/bad compressed data! */
++
++ method = makeword(eb + (EB_HEADSIZE + compr_offset));
++ if ((method == STORED) && (eb_size - compr_offset != eb_ucsize))
++ return PK_ERR; /* compressed & uncompressed
++ * should match in STORED
++ * method */
+
+ if (
+ #ifdef INT_16BIT
Property changes on: trunk/archivers/unzip/files/patch-extract.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
More information about the Midnightbsd-cvs
mailing list