summaryrefslogtreecommitdiff
path: root/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-08-16 13:56:12 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-08-16 19:02:51 +0000
commita169364e46956875db35fb1baacc4a0a1ee17f08 (patch)
tree27900d44d1655402bf52bf72c86fc429df9aaacd /xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp
parent75c65210c59de575f5a536f53bab9018b6edbed9 (diff)
downloadpdfium-a169364e46956875db35fb1baacc4a0a1ee17f08.tar.xz
Add parse depth limit to FormCalc parser
Due to the recursive nature of the FormCalc parser, deeply nested expressions can lead to memory being exhausted. This check is being added to have the parser exit early instead of running out of memory. This should reduce the number of false positives about addressing issues being found by fuzzers. BUG=chromium:752433 Change-Id: I511ecfb07e32073555e1fd1658f3b8b47f1a5a91 Reviewed-on: https://pdfium-review.googlesource.com/11170 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp')
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp b/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp
index 9907890e83..214fd4aec3 100644
--- a/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp
@@ -107,3 +107,10 @@ TEST(CXFA_FMParserTest, Parse) {
EXPECT_TRUE(ast->ToJavaScript(buf));
EXPECT_EQ(ret, buf.AsStringC());
}
+
+TEST(CXFA_FMParserTest, MaxParseDepth) {
+ auto parser = pdfium::MakeUnique<CXFA_FMParser>(L"foo(bar[baz(fizz[0])])");
+ parser->SetMaxParseDepthForTest(5);
+ EXPECT_EQ(nullptr, parser->Parse());
+ EXPECT_TRUE(parser->HasError());
+}