Guard against malformed input files
Ensure the archive start offset can never be negative. Fixes a case found by OSSFuzz.
This commit is contained in:
parent
3c46a05141
commit
0283a1796e
@ -790,6 +790,9 @@ static int mz_stat64(const char *path, struct __stat64 *buffer)
|
|||||||
if ((cdir_ofs + (mz_uint64)cdir_size) > pZip->m_archive_size)
|
if ((cdir_ofs + (mz_uint64)cdir_size) > pZip->m_archive_size)
|
||||||
return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
|
return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
|
||||||
|
|
||||||
|
if (eocd_ofs < cdir_ofs + cdir_size)
|
||||||
|
return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
|
||||||
|
|
||||||
/* The end of central dir follows the central dir, unless the zip file has
|
/* The end of central dir follows the central dir, unless the zip file has
|
||||||
* some trailing data (e.g. it is appended to an executable file). */
|
* some trailing data (e.g. it is appended to an executable file). */
|
||||||
archive_ofs = eocd_ofs - (cdir_ofs + cdir_size);
|
archive_ofs = eocd_ofs - (cdir_ofs + cdir_size);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user