commit | a607dd50d24e54eef404195cf49db0d56985a680 | [log] [tgz] |
---|---|---|
author | Tom Sepez <tsepez@chromium.org> | Thu May 12 22:43:56 2022 +0000 |
committer | Pdfium LUCI CQ <pdfium-scoped@luci-project-accounts.iam.gserviceaccount.com> | Thu May 12 22:43:56 2022 +0000 |
tree | 8baf861ac231d0960bcd4eeedfc620b522856260 | |
parent | d6189f4cb7956181517f56b37fa97c98756a741e [diff] |
CHECK() on negative sizes in CPDF_SyntaxParser::SetPos(). This would have diagnosed two recent bugs. Change-Id: I2598ca813c784587620088f0d529be94294f601a Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/93613 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp index 61532d2..e8edc42 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp +++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
@@ -481,6 +481,7 @@ } void CPDF_SyntaxParser::SetPos(FX_FILESIZE pos) { + CHECK_GE(pos, 0); m_Pos = std::min(pos, m_FileLen); }
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp b/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp index 9ccaf31..1c7d92d 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp
@@ -87,9 +87,6 @@ parser.SetPos(6); EXPECT_EQ("", parser.ReadHexString()); - parser.SetPos(-1); - EXPECT_EQ("", parser.ReadHexString()); - parser.SetPos(std::numeric_limits<FX_FILESIZE>::max()); EXPECT_EQ("", parser.ReadHexString());