| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "core/include/fpdfapi/fpdf_parser.h" | 7 #include "core/include/fpdfapi/fpdf_parser.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 2145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2156 dwSignValuePos = m_Pos; | 2156 dwSignValuePos = m_Pos; |
| 2157 | 2157 |
| 2158 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum, nullptr, true); | 2158 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum, nullptr, true); |
| 2159 if (!pObj) | 2159 if (!pObj) |
| 2160 continue; | 2160 continue; |
| 2161 | 2161 |
| 2162 CFX_ByteStringC keyNoSlash(key.c_str() + 1, key.GetLength() - 1); | 2162 CFX_ByteStringC keyNoSlash(key.c_str() + 1, key.GetLength() - 1); |
| 2163 pDict->SetAt(keyNoSlash, pObj); | 2163 pDict->SetAt(keyNoSlash, pObj); |
| 2164 } | 2164 } |
| 2165 | 2165 |
| 2166 if (IsSignatureDict(pDict.get())) { | 2166 // Only when this is a signature dictionary and has contents, we reset the |
| 2167 FX_FILESIZE dwSavePos = m_Pos; | 2167 // contents to the un-decrypted form. |
| 2168 if (IsSignatureDict(pDict.get()) && dwSignValuePos) { |
| 2169 CFX_AutoRestorer<FX_FILESIZE> save_pos(&m_Pos); |
| 2168 m_Pos = dwSignValuePos; | 2170 m_Pos = dwSignValuePos; |
| 2169 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum, nullptr, FALSE); | 2171 CPDF_Object* pObj = GetObject(pObjList, objnum, gennum, nullptr, FALSE); |
| 2170 pDict->SetAt("Contents", pObj); | 2172 pDict->SetAt("Contents", pObj); |
| 2171 m_Pos = dwSavePos; | |
| 2172 } | 2173 } |
| 2173 if (pContext) { | 2174 if (pContext) { |
| 2174 pContext->m_DictEnd = m_Pos; | 2175 pContext->m_DictEnd = m_Pos; |
| 2175 if (pContext->m_Flags & PDFPARSE_NOSTREAM) { | 2176 if (pContext->m_Flags & PDFPARSE_NOSTREAM) { |
| 2176 return pDict.release(); | 2177 return pDict.release(); |
| 2177 } | 2178 } |
| 2178 } | 2179 } |
| 2179 FX_FILESIZE SavedPos = m_Pos; | 2180 FX_FILESIZE SavedPos = m_Pos; |
| 2180 CFX_ByteString nextword = GetNextWord(nullptr); | 2181 CFX_ByteString nextword = GetNextWord(nullptr); |
| 2181 if (nextword != "stream") { | 2182 if (nextword != "stream") { |
| (...skipping 2799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4981 if (!m_pLinearizedDict) | 4982 if (!m_pLinearizedDict) |
| 4982 return -1; | 4983 return -1; |
| 4983 CPDF_Array* pRange = m_pLinearizedDict->GetArray("H"); | 4984 CPDF_Array* pRange = m_pLinearizedDict->GetArray("H"); |
| 4984 if (!pRange) | 4985 if (!pRange) |
| 4985 return -1; | 4986 return -1; |
| 4986 CPDF_Object* pStreamLen = pRange->GetElementValue(1); | 4987 CPDF_Object* pStreamLen = pRange->GetElementValue(1); |
| 4987 if (!pStreamLen) | 4988 if (!pStreamLen) |
| 4988 return -1; | 4989 return -1; |
| 4989 return pStreamLen->GetInteger(); | 4990 return pStreamLen->GetInteger(); |
| 4990 } | 4991 } |
| OLD | NEW |