diff options
author | Artem Strygin <art-snake@yandex-team.ru> | 2018-07-18 03:42:38 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-07-18 03:42:38 +0000 |
commit | a18536af5b32b63f795d8b5812a4303c7ee6ea97 (patch) | |
tree | 6522c1588f4ad073486abc9ef789bdedb0bd1357 /core/fpdfapi/parser/cpdf_parser.cpp | |
parent | 89063ecda876e3be7df5935860235eb5f8199ded (diff) | |
download | pdfium-a18536af5b32b63f795d8b5812a4303c7ee6ea97.tar.xz |
Make CPDF_Parser::GetTrailer const method.
Use own copy of encryption dictionary within CPDF_Parser,
to prevent modification of original trailer.
Change-Id: I6246b872d431b94411fcec694c5176f8d85dfe26
Reviewed-on: https://pdfium-review.googlesource.com/35450
Commit-Queue: Art Snake <art-snake@yandex-team.ru>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi/parser/cpdf_parser.cpp')
-rw-r--r-- | core/fpdfapi/parser/cpdf_parser.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp index f7846eff31..8d4d7728ab 100644 --- a/core/fpdfapi/parser/cpdf_parser.cpp +++ b/core/fpdfapi/parser/cpdf_parser.cpp @@ -185,8 +185,8 @@ bool CPDF_Parser::IsObjectFree(uint32_t objnum) const { return GetObjectType(objnum) == ObjectType::kFree; } -void CPDF_Parser::SetEncryptDictionary(CPDF_Dictionary* pDict) { - m_pEncryptDict = pDict; +void CPDF_Parser::SetEncryptDictionary(const CPDF_Dictionary* pDict) { + m_pEncryptDict = pDict ? ToDictionary(pDict->Clone()) : nullptr; } RetainPtr<IFX_SeekableReadStream> CPDF_Parser::GetFileAccess() const { @@ -338,11 +338,11 @@ CPDF_Parser::Error CPDF_Parser::SetEncryptHandler() { if (!GetTrailer()) return FORMAT_ERROR; - CPDF_Object* pEncryptObj = GetTrailer()->GetObjectFor("Encrypt"); + const CPDF_Object* pEncryptObj = GetTrailer()->GetObjectFor("Encrypt"); if (pEncryptObj) { - if (CPDF_Dictionary* pEncryptDict = pEncryptObj->AsDictionary()) { + if (const CPDF_Dictionary* pEncryptDict = pEncryptObj->AsDictionary()) { SetEncryptDictionary(pEncryptDict); - } else if (CPDF_Reference* pRef = pEncryptObj->AsReference()) { + } else if (const CPDF_Reference* pRef = pEncryptObj->AsReference()) { pEncryptObj = m_pObjectsHolder->GetOrParseIndirectObject(pRef->GetRefObjNum()); if (pEncryptObj) @@ -357,7 +357,7 @@ CPDF_Parser::Error CPDF_Parser::SetEncryptHandler() { std::unique_ptr<CPDF_SecurityHandler> pSecurityHandler = pdfium::MakeUnique<CPDF_SecurityHandler>(); - if (!pSecurityHandler->OnInit(m_pEncryptDict.Get(), GetIDArray(), + if (!pSecurityHandler->OnInit(m_pEncryptDict.get(), GetIDArray(), m_Password)) return PASSWORD_ERROR; @@ -1112,7 +1112,7 @@ CPDF_Dictionary* CPDF_Parser::GetRoot() const { return obj ? obj->GetDict() : nullptr; } -CPDF_Dictionary* CPDF_Parser::GetTrailer() const { +const CPDF_Dictionary* CPDF_Parser::GetTrailer() const { return m_TrailerData->GetMainTrailer(); } |