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

Side by Side Diff: core/fpdfapi/fpdf_page/cpdf_psengine.h

Issue 2350013003: Fix stack exhaustion in CPDF_PSProc::Parse() (Closed)
Patch Set: stray file Created 4 years, 3 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 | « no previous file | core/fpdfapi/fpdf_page/fpdf_page_func.cpp » ('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 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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_FPDFAPI_FPDF_PAGE_CPDF_PSENGINE_H_ 7 #ifndef CORE_FPDFAPI_FPDF_PAGE_CPDF_PSENGINE_H_
8 #define CORE_FPDFAPI_FPDF_PAGE_CPDF_PSENGINE_H_ 8 #define CORE_FPDFAPI_FPDF_PAGE_CPDF_PSENGINE_H_
9 9
10 #include <memory> 10 #include <memory>
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 PSOP_CONST 63 PSOP_CONST
64 }; 64 };
65 65
66 constexpr uint32_t PSENGINE_STACKSIZE = 100; 66 constexpr uint32_t PSENGINE_STACKSIZE = 100;
67 67
68 class CPDF_PSProc { 68 class CPDF_PSProc {
69 public: 69 public:
70 CPDF_PSProc(); 70 CPDF_PSProc();
71 ~CPDF_PSProc(); 71 ~CPDF_PSProc();
72 72
73 FX_BOOL Parse(CPDF_SimpleParser* parser); 73 FX_BOOL Parse(CPDF_SimpleParser* parser, int depth);
74 FX_BOOL Execute(CPDF_PSEngine* pEngine); 74 FX_BOOL Execute(CPDF_PSEngine* pEngine);
75 75
76 private: 76 private:
77 static const int kMaxDepth = 128;
77 std::vector<std::unique_ptr<CPDF_PSOP>> m_Operators; 78 std::vector<std::unique_ptr<CPDF_PSOP>> m_Operators;
78 }; 79 };
79 80
80 class CPDF_PSEngine { 81 class CPDF_PSEngine {
81 public: 82 public:
82 CPDF_PSEngine(); 83 CPDF_PSEngine();
83 ~CPDF_PSEngine(); 84 ~CPDF_PSEngine();
84 85
85 FX_BOOL Parse(const FX_CHAR* str, int size); 86 FX_BOOL Parse(const FX_CHAR* str, int size);
86 FX_BOOL Execute(); 87 FX_BOOL Execute();
87 FX_BOOL DoOperator(PDF_PSOP op); 88 FX_BOOL DoOperator(PDF_PSOP op);
88 void Reset() { m_StackCount = 0; } 89 void Reset() { m_StackCount = 0; }
89 void Push(FX_FLOAT value); 90 void Push(FX_FLOAT value);
90 void Push(int value) { Push((FX_FLOAT)value); } 91 void Push(int value) { Push((FX_FLOAT)value); }
91 FX_FLOAT Pop(); 92 FX_FLOAT Pop();
92 uint32_t GetStackSize() const { return m_StackCount; } 93 uint32_t GetStackSize() const { return m_StackCount; }
93 94
94 private: 95 private:
95 FX_FLOAT m_Stack[PSENGINE_STACKSIZE]; 96 FX_FLOAT m_Stack[PSENGINE_STACKSIZE];
96 uint32_t m_StackCount; 97 uint32_t m_StackCount;
97 CPDF_PSProc m_MainProc; 98 CPDF_PSProc m_MainProc;
98 }; 99 };
99 100
100 #endif // CORE_FPDFAPI_FPDF_PAGE_CPDF_PSENGINE_H_ 101 #endif // CORE_FPDFAPI_FPDF_PAGE_CPDF_PSENGINE_H_
OLDNEW
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_page/fpdf_page_func.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698