ofz: pdf, clamp stream Length to the bytes actually read

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I155f3eddbd204069084b50f52f7cc6328fb053eb
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/6118
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
Reviewed-by: Noel Grandin <noel.grandin@collabora.com>
(cherry picked from commit 332e8831e0b0e580dae0d77a0ec27bd267af6b29)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207660
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
Caolán McNamara
2026-07-06 12:29:35 +02:00
committed by Xisco Fauli
parent 28711b69f5
commit dcf16d610a
@@ -688,6 +688,12 @@ bool PDFObject::getDeflatedStream( std::unique_ptr<char[]>& rpStream, unsigned i
pStream++;
// get the compressed length
*pBytes = m_pStream->getDictLength( pObjectContainer );
unsigned int nAvailable = nOuterStreamLen - static_cast<unsigned int>(pStream - rpStream.get());
if (*pBytes > nAvailable)
{
SAL_WARN("sdext.pdfimport.pdfparse", "stream /Length " << *pBytes << " exceeds " << nAvailable << " available bytes");
*pBytes = nAvailable;
}
if( pStream != rpStream.get() )
memmove( rpStream.get(), pStream, *pBytes );
if( rContext.m_bDecrypt )