Blame SOURCES/unzip-6.0-cve-2014-8139.patch

7e0a4d
diff --git a/extract.c b/extract.c
7e0a4d
index 9ef80b3..c741b5f 100644
7e0a4d
--- a/extract.c
7e0a4d
+++ b/extract.c
7e0a4d
@@ -1,5 +1,5 @@
7e0a4d
 /*
7e0a4d
-  Copyright (c) 1990-2009 Info-ZIP.  All rights reserved.
7e0a4d
+  Copyright (c) 1990-2014 Info-ZIP.  All rights reserved.
7e0a4d
 
7e0a4d
   See the accompanying file LICENSE, version 2009-Jan-02 or later
7e0a4d
   (the contents of which are also included in unzip.h) for terms of use.
7e0a4d
@@ -298,6 +298,8 @@ char ZCONST Far TruncNTSD[] =
7e0a4d
 #ifndef SFX
7e0a4d
    static ZCONST char Far InconsistEFlength[] = "bad extra-field entry:\n \
7e0a4d
      EF block length (%u bytes) exceeds remaining EF data (%u bytes)\n";
7e0a4d
+   static ZCONST char Far TooSmallEBlength[] = "bad extra-field entry:\n \
7e0a4d
+     EF block length (%u bytes) invalid (< %d)\n";
7e0a4d
    static ZCONST char Far InvalidComprDataEAs[] =
7e0a4d
      " invalid compressed data for EAs\n";
7e0a4d
 #  if (defined(WIN32) && defined(NTSD_EAS))
7e0a4d
@@ -2020,7 +2022,8 @@ static int TestExtraField(__G__ ef, ef_len)
7e0a4d
         ebID = makeword(ef);
7e0a4d
         ebLen = (unsigned)makeword(ef+EB_LEN);
7e0a4d
 
7e0a4d
-        if (ebLen > (ef_len - EB_HEADSIZE)) {
7e0a4d
+        if (ebLen > (ef_len - EB_HEADSIZE))
7e0a4d
+        {
7e0a4d
            /* Discovered some extra field inconsistency! */
7e0a4d
             if (uO.qflag)
7e0a4d
                 Info(slide, 1, ((char *)slide, "%-22s ",
7e0a4d
@@ -2155,11 +2158,29 @@ static int TestExtraField(__G__ ef, ef_len)
7e0a4d
                 }
7e0a4d
                 break;
7e0a4d
             case EF_PKVMS:
7e0a4d
-                if (makelong(ef+EB_HEADSIZE) !=
7e0a4d
-                    crc32(CRCVAL_INITIAL, ef+(EB_HEADSIZE+4),
7e0a4d
-                          (extent)(ebLen-4)))
7e0a4d
-                    Info(slide, 1, ((char *)slide,
7e0a4d
-                      LoadFarString(BadCRC_EAs)));
7e0a4d
+                /* 2015-01-30 SMS.  Added sufficient-bytes test/message
7e0a4d
+                 * here.  (Removed defective ebLen test above.)
7e0a4d
+                 *
7e0a4d
+                 * If sufficient bytes (EB_PKVMS_MINLEN) are available,
7e0a4d
+                 * then compare the stored CRC value with the calculated
7e0a4d
+                 * CRC for the remainder of the data (and complain about
7e0a4d
+                 * a mismatch).
7e0a4d
+                 */
7e0a4d
+                if (ebLen < EB_PKVMS_MINLEN)
7e0a4d
+                {
7e0a4d
+                    /* Insufficient bytes available. */
7e0a4d
+                    Info( slide, 1,
7e0a4d
+                     ((char *)slide, LoadFarString( TooSmallEBlength),
7e0a4d
+                     ebLen, EB_PKVMS_MINLEN));
7e0a4d
+                }
7e0a4d
+                else if (makelong(ef+ EB_HEADSIZE) !=
7e0a4d
+                 crc32(CRCVAL_INITIAL,
7e0a4d
+                 (ef+ EB_HEADSIZE+ EB_PKVMS_MINLEN),
7e0a4d
+                 (extent)(ebLen- EB_PKVMS_MINLEN)))
7e0a4d
+                {
7e0a4d
+                     Info(slide, 1, ((char *)slide,
7e0a4d
+                       LoadFarString(BadCRC_EAs)));
7e0a4d
+                }
7e0a4d
                 break;
7e0a4d
             case EF_PKW32:
7e0a4d
             case EF_PKUNIX:
7e0a4d
diff --git a/unzpriv.h b/unzpriv.h
7e0a4d
index 005cee0..5c83a6e 100644
7e0a4d
--- a/unzpriv.h
7e0a4d
+++ b/unzpriv.h
7e0a4d
@@ -1806,6 +1806,8 @@
7e0a4d
 #define EB_NTSD_VERSION   4    /* offset of NTSD version byte */
7e0a4d
 #define EB_NTSD_MAX_VER   (0)  /* maximum version # we know how to handle */
7e0a4d
 
7e0a4d
+#define EB_PKVMS_MINLEN   4    /* minimum data length of PKVMS extra block */
7e0a4d
+
7e0a4d
 #define EB_ASI_CRC32      0    /* offset of ASI Unix field's crc32 checksum */
7e0a4d
 #define EB_ASI_MODE       4    /* offset of ASI Unix permission mode field */
7e0a4d
 
7e0a4d