cid#1615990 silence Overflowed integer argument

Change-Id: I37ff85c8d6363bd1e9fb1097dc107bca2ad73738
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171926
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
This commit is contained in:
Caolán McNamara 2024-08-12 12:35:39 +01:00
parent 898594dc5d
commit 4551356827

View file

@ -1304,15 +1304,13 @@ sal_Int32 ZipFile::readCEN()
if (nCenLen < nTotal * CENHDR) // prevent overflow with ZIP_MAXENTRIES
throw ZipException(u"invalid END header (bad entry count)"_ustr );
if (SAL_MAX_INT32 < nCenLen)
{
if (nCenLen > SAL_MAX_INT32 || nCenLen < 0)
throw ZipException(u"central directory too big"_ustr);
}
aGrabber.seek(nCenPos);
Sequence < sal_Int8 > aCENBuffer ( nCenLen );
Sequence<sal_Int8> aCENBuffer(nCenLen);
sal_Int64 nRead = aGrabber.readBytes ( aCENBuffer, nCenLen );
if ( static_cast < sal_Int64 > ( nCenLen ) != nRead )
if (nCenLen != nRead)
throw ZipException (u"Error reading CEN into memory buffer!"_ustr );
MemoryByteGrabber aMemGrabber(aCENBuffer);