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

Side by Side Diff: core/include/fpdfapi/fpdf_parser.h

Issue 1755273002: Fix parsing of object numbers > 16,777,216. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 9 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
« no previous file with comments | « BUILD.gn ('k') | core/include/fxcrt/fx_system.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ 7 #ifndef CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_
8 #define CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ 8 #define CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_
9 9
10 #include <map> 10 #include <map>
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 }; 232 };
233 233
234 class CPDF_SyntaxParser { 234 class CPDF_SyntaxParser {
235 public: 235 public:
236 CPDF_SyntaxParser(); 236 CPDF_SyntaxParser();
237 virtual ~CPDF_SyntaxParser(); 237 virtual ~CPDF_SyntaxParser();
238 238
239 void InitParser(IFX_FileRead* pFileAccess, FX_DWORD HeaderOffset); 239 void InitParser(IFX_FileRead* pFileAccess, FX_DWORD HeaderOffset);
240 240
241 FX_FILESIZE SavePos() const { return m_Pos; } 241 FX_FILESIZE SavePos() const { return m_Pos; }
242
243 void RestorePos(FX_FILESIZE pos) { m_Pos = pos; } 242 void RestorePos(FX_FILESIZE pos) { m_Pos = pos; }
244 243
245 CPDF_Object* GetObject(CPDF_IndirectObjectHolder* pObjList, 244 CPDF_Object* GetObject(CPDF_IndirectObjectHolder* pObjList,
246 FX_DWORD objnum, 245 FX_DWORD objnum,
247 FX_DWORD gennum, 246 FX_DWORD gennum,
248 FX_BOOL bDecrypt); 247 FX_BOOL bDecrypt);
249
250 CPDF_Object* GetObjectByStrict(CPDF_IndirectObjectHolder* pObjList, 248 CPDF_Object* GetObjectByStrict(CPDF_IndirectObjectHolder* pObjList,
251 FX_DWORD objnum, 249 FX_DWORD objnum,
252 FX_DWORD gennum); 250 FX_DWORD gennum);
253
254 int GetDirectNum();
255
256 CFX_ByteString GetKeyword(); 251 CFX_ByteString GetKeyword();
257 252
258 void ToNextLine(); 253 void ToNextLine();
259
260 void ToNextWord(); 254 void ToNextWord();
261 255
262 FX_BOOL SearchWord(const CFX_ByteStringC& word, 256 FX_BOOL SearchWord(const CFX_ByteStringC& word,
263 FX_BOOL bWholeWord, 257 FX_BOOL bWholeWord,
264 FX_BOOL bForward, 258 FX_BOOL bForward,
265 FX_FILESIZE limit); 259 FX_FILESIZE limit);
266
267 int SearchMultiWord(const CFX_ByteStringC& words, 260 int SearchMultiWord(const CFX_ByteStringC& words,
268 FX_BOOL bWholeWord, 261 FX_BOOL bWholeWord,
269 FX_FILESIZE limit); 262 FX_FILESIZE limit);
270
271 FX_FILESIZE FindTag(const CFX_ByteStringC& tag, FX_FILESIZE limit); 263 FX_FILESIZE FindTag(const CFX_ByteStringC& tag, FX_FILESIZE limit);
272 264
273 void SetEncrypt(std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler); 265 void SetEncrypt(std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler);
274 266
267 FX_BOOL ReadBlock(uint8_t* pBuf, FX_DWORD size);
275 FX_BOOL GetCharAt(FX_FILESIZE pos, uint8_t& ch); 268 FX_BOOL GetCharAt(FX_FILESIZE pos, uint8_t& ch);
276
277 FX_BOOL ReadBlock(uint8_t* pBuf, FX_DWORD size);
278
279 CFX_ByteString GetNextWord(bool* bIsNumber); 269 CFX_ByteString GetNextWord(bool* bIsNumber);
280 270
281 protected: 271 protected:
282 friend class CPDF_Parser; 272 friend class CPDF_Parser;
283 friend class CPDF_DataAvail; 273 friend class CPDF_DataAvail;
284 friend class fpdf_parser_parser_ReadHexString_Test; 274 friend class fpdf_parser_parser_ReadHexString_Test;
285 275
286 static const int kParserMaxRecursionDepth = 64; 276 static const int kParserMaxRecursionDepth = 64;
287 static int s_CurrentRecursionDepth; 277 static int s_CurrentRecursionDepth;
288 278
(...skipping 22 matching lines...) Expand all
311 int m_MetadataObjnum; 301 int m_MetadataObjnum;
312 IFX_FileRead* m_pFileAccess; 302 IFX_FileRead* m_pFileAccess;
313 FX_DWORD m_HeaderOffset; 303 FX_DWORD m_HeaderOffset;
314 FX_FILESIZE m_FileLen; 304 FX_FILESIZE m_FileLen;
315 uint8_t* m_pFileBuf; 305 uint8_t* m_pFileBuf;
316 FX_DWORD m_BufSize; 306 FX_DWORD m_BufSize;
317 FX_FILESIZE m_BufOffset; 307 FX_FILESIZE m_BufOffset;
318 std::unique_ptr<CPDF_CryptoHandler> m_pCryptoHandler; 308 std::unique_ptr<CPDF_CryptoHandler> m_pCryptoHandler;
319 uint8_t m_WordBuffer[257]; 309 uint8_t m_WordBuffer[257];
320 FX_DWORD m_WordSize; 310 FX_DWORD m_WordSize;
311
312 private:
313 uint32_t GetDirectNum();
321 }; 314 };
322 315
323 class CPDF_Parser { 316 class CPDF_Parser {
324 public: 317 public:
325 enum Error { 318 enum Error {
326 SUCCESS = 0, 319 SUCCESS = 0,
327 FILE_ERROR, 320 FILE_ERROR,
328 FORMAT_ERROR, 321 FORMAT_ERROR,
329 PASSWORD_ERROR, 322 PASSWORD_ERROR,
330 HANDLER_ERROR 323 HANDLER_ERROR
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 FX_DWORD src_size, 857 FX_DWORD src_size,
865 const CPDF_Dictionary* pDict, 858 const CPDF_Dictionary* pDict,
866 uint8_t*& dest_buf, 859 uint8_t*& dest_buf,
867 FX_DWORD& dest_size, 860 FX_DWORD& dest_size,
868 CFX_ByteString& ImageEncoding, 861 CFX_ByteString& ImageEncoding,
869 CPDF_Dictionary*& pImageParms, 862 CPDF_Dictionary*& pImageParms,
870 FX_DWORD estimated_size, 863 FX_DWORD estimated_size,
871 FX_BOOL bImageAcc); 864 FX_BOOL bImageAcc);
872 865
873 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ 866 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | core/include/fxcrt/fx_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698