Fix buffer read overflow in ZIP-64 loading code

Don't even try to parse the ZIP-64 header if there is not enough data in
the file.

Credit to OSS-Fuzz: this solves its issue 16250.
This commit is contained in:
Vadim Zeitlin
2019-10-29 19:01:48 +01:00
parent e790f03950
commit c836b94cc4

View File

@@ -1542,6 +1542,8 @@ bool wxZipEndRec::Read(wxInputStream& stream, wxMBConv& conv)
if (stream.SeekI(z64EndOffset) == wxInvalidOffset)
return false;
wxZipHeader dsEnd(stream, Z64_END_SIZE);
if ( !dsEnd )
return false;
if ( dsEnd.Read32() != Z64_END_MAGIC ||
dsEnd.Read64() < Z64_END_SIZE - 12 ) // Check record size
return false;