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