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