Kaydet (Commit) 0c43c330 authored tarafından Miklos Vajna's avatar Miklos Vajna Kaydeden (comit) Andras Timar

forcepoint #16: fix heap-use-after-free

PDFDocument::Tokenize() in the aKeyword == "obj" case allocates a
PDFObjectElement, stores it as an owning pointer inside rElements, and
also stores two non-owning references to it in m_aOffsetObjects and
m_aIDObjects. So make sure those 2 other containers are also cleared
then elements go away.

LO_TRACE="valgrind" bin/run pdfverify <sample>

doesn't report errors anymore after the fix.

Reviewed-on: https://gerrit.libreoffice.org/50632Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
(cherry picked from commit 506d4cbc)

Change-Id: Ie103de3e24a1080257a79e53b994e8536a9597bc
üst e112fe43
...@@ -1280,8 +1280,10 @@ bool PDFDocument::Read(SvStream& rStream) ...@@ -1280,8 +1280,10 @@ bool PDFDocument::Read(SvStream& rStream)
if (pPrev) if (pPrev)
nStartXRef = pPrev->GetValue(); nStartXRef = pPrev->GetValue();
// Reset state, except object offsets and the edit buffer. // Reset state, except the edit buffer.
m_aElements.clear(); m_aElements.clear();
m_aOffsetObjects.clear();
m_aIDObjects.clear();
m_aStartXRefs.clear(); m_aStartXRefs.clear();
m_aEOFs.clear(); m_aEOFs.clear();
m_pTrailer = nullptr; m_pTrailer = nullptr;
......
...@@ -416,6 +416,8 @@ void PDFSigningTest::testTokenize() ...@@ -416,6 +416,8 @@ void PDFSigningTest::testTokenize()
// File that's intentionally smaller than 1024 bytes. // File that's intentionally smaller than 1024 bytes.
OUStringLiteral("small.pdf"), OUStringLiteral("small.pdf"),
OUStringLiteral("tdf107149.pdf"), OUStringLiteral("tdf107149.pdf"),
// Valgrind was unhappy about this.
OUStringLiteral("forcepoint16.pdf"),
}; };
for (const auto& rName : aNames) for (const auto& rName : aNames)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment