summaryrefslogtreecommitdiff
path: root/Build/source/libs/poppler/poppler-src/poppler/Parser.cc
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/poppler/poppler-src/poppler/Parser.cc')
-rw-r--r--Build/source/libs/poppler/poppler-src/poppler/Parser.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/Build/source/libs/poppler/poppler-src/poppler/Parser.cc b/Build/source/libs/poppler/poppler-src/poppler/Parser.cc
index 869e94ad0c8..39c9a96720b 100644
--- a/Build/source/libs/poppler/poppler-src/poppler/Parser.cc
+++ b/Build/source/libs/poppler/poppler-src/poppler/Parser.cc
@@ -13,7 +13,7 @@
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
-// Copyright (C) 2006, 2009, 201, 2010, 2013, 2014, 2017 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2006, 2009, 201, 2010, 2013, 2014, 2017, 2018 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright (C) 2009 Ilya Gorenbein <igorenbein@finjan.com>
// Copyright (C) 2012 Hib Eris <hib@hiberis.nl>
@@ -235,6 +235,12 @@ Stream *Parser::makeStream(Object &&dict, Guchar *fileKey,
pos = pos - 1;
lexer->lookCharLastValueCached = Lexer::LOOK_VALUE_NOT_CACHED;
}
+ if (unlikely(length < 0)) {
+ return nullptr;
+ }
+ if (unlikely(pos > LLONG_MAX - length)) {
+ return nullptr;
+ }
lexer->setPos(pos + length);
// refill token buffers and check for 'endstream'
@@ -255,7 +261,8 @@ Stream *Parser::makeStream(Object &&dict, Guchar *fileKey,
// When building the xref we can't use it so use this
// kludge for broken PDF files: just add 5k to the length, and
// hope its enough
- length += 5000;
+ if (length < LLONG_MAX - 5000)
+ length += 5000;
}
}