]> granicus.if.org Git - php/commitdiff
Apply upstream patch for CVE-2017-14107
authorAnatol Belski <ab@php.net>
Fri, 27 Oct 2017 11:20:15 +0000 (13:20 +0200)
committerAnatol Belski <ab@php.net>
Fri, 27 Oct 2017 11:20:15 +0000 (13:20 +0200)
ext/zip/lib/zip_open.c

index d6209ee1e769e62fffbe858cf34a8d210319f8f0..29409b747dbea836587ec3f8ac197dfe892f95f4 100644 (file)
@@ -837,7 +837,12 @@ _zip_read_eocd64(zip_source_t *src, zip_buffer_t *buffer, zip_uint64_t buf_offse
         zip_error_set(error, ZIP_ER_SEEK, EFBIG);
         return NULL;
     }
-    if ((flags & ZIP_CHECKCONS) && offset+size != eocd_offset) {
+    if (offset+size > buf_offset + eocd_offset) {
+       /* cdir spans past EOCD record */
+       zip_error_set(error, ZIP_ER_INCONS, 0);
+       return NULL;
+    }
+    if ((flags & ZIP_CHECKCONS) && offset+size != buf_offset + eocd_offset) {
        zip_error_set(error, ZIP_ER_INCONS, 0);
        return NULL;
     }