summaryrefslogtreecommitdiff
path: root/core/include
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-01-26 16:59:09 -0800
committerTom Sepez <tsepez@chromium.org>2015-01-26 16:59:09 -0800
commite80685c12c3620c178a2286e00dd03c7886f8785 (patch)
treeb33f78a6f516b7483e689a2f9138a35b328d565e /core/include
parentf290eed6f2d0c59e89db1374f9e6b254b51a2356 (diff)
downloadpdfium-e80685c12c3620c178a2286e00dd03c7886f8785.tar.xz
Merge to XFA: Fix infinite recursion in CPDF_Parser::ParseIndirectObjectAt().
Orignal Review URL: https://codereview.chromium.org/875263002 TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/880753002
Diffstat (limited to 'core/include')
-rw-r--r--core/include/fpdfapi/fpdf_parser.h7
-rw-r--r--core/include/fxcrt/fx_basic.h15
2 files changed, 19 insertions, 3 deletions
diff --git a/core/include/fpdfapi/fpdf_parser.h b/core/include/fpdfapi/fpdf_parser.h
index 3f9bda5ad8..e1a0f5cf1a 100644
--- a/core/include/fpdfapi/fpdf_parser.h
+++ b/core/include/fpdfapi/fpdf_parser.h
@@ -261,10 +261,10 @@ public:
m_Pos = pos;
}
- CPDF_Object* GetObject(CPDF_IndirectObjects* pObjList, FX_DWORD objnum, FX_DWORD gennum, int level, struct PARSE_CONTEXT* pContext = NULL, FX_BOOL bDecrypt = TRUE);
+ CPDF_Object* GetObject(CPDF_IndirectObjects* pObjList, FX_DWORD objnum, FX_DWORD gennum, struct PARSE_CONTEXT* pContext = NULL, FX_BOOL bDecrypt = TRUE);
- CPDF_Object* GetObjectByStrict(CPDF_IndirectObjects* pObjList, FX_DWORD objnum, FX_DWORD gennum, int level, struct PARSE_CONTEXT* pContext = NULL);
+ CPDF_Object* GetObjectByStrict(CPDF_IndirectObjects* pObjList, FX_DWORD objnum, FX_DWORD gennum, struct PARSE_CONTEXT* pContext = NULL);
int GetDirectNum();
@@ -302,6 +302,8 @@ public:
CFX_ByteString GetNextWord(FX_BOOL& bIsNumber);
protected:
+ static const int kParserMaxRecursionDepth = 64;
+ static int s_CurrentRecursionDepth;
virtual FX_BOOL GetNextChar(FX_BYTE& ch);
@@ -520,7 +522,6 @@ public:
return m_dwFirstPageNo;
}
protected:
-
CPDF_Document* m_pDocument;
CPDF_SyntaxParser m_Syntax;
diff --git a/core/include/fxcrt/fx_basic.h b/core/include/fxcrt/fx_basic.h
index 1c828cea48..b63327c9c2 100644
--- a/core/include/fxcrt/fx_basic.h
+++ b/core/include/fxcrt/fx_basic.h
@@ -1414,6 +1414,21 @@ protected:
CFX_DataFilter* m_pDestFilter;
};
+
+template<typename T>
+class CFX_AutoRestorer {
+public:
+ explicit CFX_AutoRestorer(T* location) {
+ m_Location = location;
+ m_OldValue = *location;
+ }
+ ~CFX_AutoRestorer() { *m_Location = m_OldValue; }
+
+private:
+ T* m_Location;
+ T m_OldValue;
+};
+
template <class T>
class CFX_SmartPointer
{