From 21124741e0134f0f1222a42726c223bf6da41dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Sat, 4 Jul 2026 15:43:32 +0100 Subject: [PATCH] ofz: pdf, check record againsts max allowed size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Caolán McNamara Change-Id: I51a31c1e09d2b5d5a413c5345c40998e032f09d6 Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/6117 Tested-by: Jenkins CPCI Reviewed-by: Noel Grandin (cherry picked from commit e230b10b7cd2d5d8623cdba0877ec68f67003690) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207659 Reviewed-by: Xisco Fauli Tested-by: Jenkins --- sdext/source/pdfimport/pdfparse/pdfentries.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sdext/source/pdfimport/pdfparse/pdfentries.cxx b/sdext/source/pdfimport/pdfparse/pdfentries.cxx index 3ec950e22b75..67ad3af2cb96 100644 --- a/sdext/source/pdfimport/pdfparse/pdfentries.cxx +++ b/sdext/source/pdfimport/pdfparse/pdfentries.cxx @@ -1339,7 +1339,15 @@ PDFFileImplData* PDFFile::impl_getData() const { PDFNumber* pNum = dynamic_cast(len->second); if( pNum ) - m_pData->m_nKeyLength = static_cast(pNum->m_fValue) / 8; + { + sal_uInt32 nKeyLength = static_cast(pNum->m_fValue) / 8; + if (nKeyLength > ENCRYPTION_KEY_LEN) + { + SAL_WARN("sdext.pdfimport.pdfparse", "entry has length " << nKeyLength << " which is greater than " << ENCRYPTION_KEY_LEN); + nKeyLength = ENCRYPTION_KEY_LEN; + } + m_pData->m_nKeyLength = nKeyLength; + } } PDFName* pFilter = dynamic_cast(filter->second); if( pFilter && pFilter->getFilteredName() == "Standard" )