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