summaryrefslogtreecommitdiff
path: root/xmlsecurity/source/pdfio/pdfdocument.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-12-01 09:42:45 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-12-01 12:29:32 +0000
commit0233ff952372e9a15edf92beccba463d74c46c33 (patch)
tree6f4ef5f640f1ef81aa3cc9af4ccb99649ebdc3b5 /xmlsecurity/source/pdfio/pdfdocument.cxx
parentd36b3bcb7e08f7f73709b7afe9b8f9ec22a0fcd2 (diff)
xmlsecurity PDF verify: tolerate missing %%EOF in incremental updates
This is broken, but work it around to avoid an infinite loop. Change-Id: I132a3c19cfe53e6166bfc1a881d1bfa5071f85d4 Reviewed-on: https://gerrit.libreoffice.org/31471 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'xmlsecurity/source/pdfio/pdfdocument.cxx')
-rw-r--r--xmlsecurity/source/pdfio/pdfdocument.cxx12
1 files changed, 8 insertions, 4 deletions
diff --git a/xmlsecurity/source/pdfio/pdfdocument.cxx b/xmlsecurity/source/pdfio/pdfdocument.cxx
index e3e89a0750ee..86aff1eb3f5a 100644
--- a/xmlsecurity/source/pdfio/pdfdocument.cxx
+++ b/xmlsecurity/source/pdfio/pdfdocument.cxx
@@ -1228,8 +1228,12 @@ bool PDFDocument::Tokenize(SvStream& rStream, TokenizeMode eMode, std::vector< s
}
else if (aKeyword == "trailer")
{
- m_pTrailer = new PDFTrailerElement(*this);
- rElements.push_back(std::unique_ptr<PDFElement>(m_pTrailer));
+ auto pTrailer = new PDFTrailerElement(*this);
+ // When reading till the first EOF token only, remember
+ // just the first trailer token.
+ if (eMode != TokenizeMode::EOF_TOKEN || !m_pTrailer)
+ m_pTrailer = pTrailer;
+ rElements.push_back(std::unique_ptr<PDFElement>(pTrailer));
}
else if (aKeyword == "startxref")
{
@@ -1680,9 +1684,9 @@ void PDFDocument::ReadXRef(SvStream& rStream)
return;
}
- if (aNumberOfEntries.GetValue() <= 0)
+ if (aNumberOfEntries.GetValue() < 0)
{
- SAL_WARN("xmlsecurity.pdfio", "PDFDocument::ReadXRef: expected one or more entries");
+ SAL_WARN("xmlsecurity.pdfio", "PDFDocument::ReadXRef: expected zero or more entries");
return;
}