check the byte ranges of a pdf signature against the file

The offsets and lengths come from the document, so a range that is
not inside the file leaves the signature unchecked now.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I4c293d4c49326cb08336295714dec91d833bbd88
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/13334
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
Reviewed-by: Noel Grandin <noel.grandin@collabora.com>
(cherry picked from commit 2fb3bbcf0afd5d13f41d526551835a24a0d8b5aa)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211454
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
Caolán McNamara
2026-09-25 19:37:47 +02:00
committed by Xisco Fauli
parent db7dd67ddb
commit 984bb7858f
2 changed files with 17 additions and 0 deletions
@@ -131,6 +131,14 @@ void GetByteRangesFromPDF(const std::unique_ptr<vcl::pdf::PDFiumSignature>& pSig
size_t nByteRangeOffset = 0;
for (size_t i = 0; i < aByteRange.size(); ++i)
{
// Only offsets and lengths that are zero or more describe a part of the file.
if (aByteRange[i] < 0)
{
SAL_WARN("xmlsecurity.helper", "GetByteRangesFromPDF: negative byte range");
rByteRanges.clear();
return;
}
if (i % 2 == 0)
{
nByteRangeOffset = aByteRange[i];