Skip to content

Commit f6e8ce8

Browse files
committed
Backport and apply upstream patch for CVE-2017-14107
1 parent f600785 commit f6e8ce8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ext/zip/lib/zip_open.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,12 @@ _zip_read_eocd64(FILE *f, const zip_uint8_t *eocd64loc, const zip_uint8_t *buf,
726726
_zip_error_set(error, ZIP_ER_SEEK, EFBIG);
727727
return NULL;
728728
}
729-
if ((flags & ZIP_CHECKCONS) && offset+size != eocd_offset) {
729+
if (offset+size > buf_offset + eocd_offset) {
730+
/* cdir spans past EOCD record */
731+
_zip_error_set(error, ZIP_ER_INCONS, 0);
732+
return NULL;
733+
}
734+
if ((flags & ZIP_CHECKCONS) && offset+size != buf_offset + eocd_offset) {
730735
_zip_error_set(error, ZIP_ER_INCONS, 0);
731736
return NULL;
732737
}

0 commit comments

Comments
 (0)