Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(585)

Side by Side Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp

Issue 1575833004: Fix an infinite loop parsing in CPDF_SyntaxParser::GetObject() (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // contents to the un-decrypted form.
2168 if (IsSignatureDict(pDict.get()) && dwSignValuePos) {
Lei Zhang 2016/01/11 19:55:02 If |dwSignValuePos| is non-zero, but still invalid
Wei Li 2016/01/11 21:07:20 Infinite loops caused during parsing should repeat
2167 FX_FILESIZE dwSavePos = m_Pos; 2169 FX_FILESIZE dwSavePos = m_Pos;
Lei Zhang 2016/01/11 19:55:02 Replace with CFX_AutoRestorer while we are here?
Wei Li 2016/01/11 21:07:20 Done.
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; 2173 m_Pos = dwSavePos;
2172 } 2174 }
2173 if (pContext) { 2175 if (pContext) {
2174 pContext->m_DictEnd = m_Pos; 2176 pContext->m_DictEnd = m_Pos;
2175 if (pContext->m_Flags & PDFPARSE_NOSTREAM) { 2177 if (pContext->m_Flags & PDFPARSE_NOSTREAM) {
2176 return pDict.release(); 2178 return pDict.release();
2177 } 2179 }
(...skipping 2803 matching lines...) Expand 10 before | Expand all | Expand 10 after
4981 if (!m_pLinearizedDict) 4983 if (!m_pLinearizedDict)
4982 return -1; 4984 return -1;
4983 CPDF_Array* pRange = m_pLinearizedDict->GetArray("H"); 4985 CPDF_Array* pRange = m_pLinearizedDict->GetArray("H");
4984 if (!pRange) 4986 if (!pRange)
4985 return -1; 4987 return -1;
4986 CPDF_Object* pStreamLen = pRange->GetElementValue(1); 4988 CPDF_Object* pStreamLen = pRange->GetElementValue(1);
4987 if (!pStreamLen) 4989 if (!pStreamLen)
4988 return -1; 4990 return -1;
4989 return pStreamLen->GetInteger(); 4991 return pStreamLen->GetInteger();
4990 } 4992 }
OLDNEW
« no previous file with comments | « no previous file | fpdfsdk/src/fpdfview_embeddertest.cpp » ('j') | fpdfsdk/src/fpdfview_embeddertest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698