|
|
a99760 |
From 81044c64b9ed9a10ae82a28bac753060bdfdac74 Mon Sep 17 00:00:00 2001
|
|
|
a99760 |
From: Albert Astals Cid <aacid@kde.org>
|
|
|
a99760 |
Date: Tue, 15 Mar 2022 15:14:32 +0100
|
|
|
a99760 |
Subject: Hints::readTables: bail out if we run out of file when reading
|
|
|
a99760 |
|
|
|
a99760 |
Fixes #1230
|
|
|
a99760 |
|
|
|
a99760 |
diff --git a/poppler/Hints.cc b/poppler/Hints.cc
|
|
|
a99760 |
index 79f04088..4707e1c6 100644
|
|
|
a99760 |
--- a/poppler/Hints.cc
|
|
|
a99760 |
+++ b/poppler/Hints.cc
|
|
|
a99760 |
@@ -5,7 +5,7 @@
|
|
|
a99760 |
// This file is licensed under the GPLv2 or later
|
|
|
a99760 |
//
|
|
|
a99760 |
// Copyright 2010, 2012 Hib Eris <hib@hiberis.nl>
|
|
|
a99760 |
-// Copyright 2010, 2011, 2013, 2014, 2016-2019 Albert Astals Cid <aacid@kde.org>
|
|
|
a99760 |
+// Copyright 2010, 2011, 2013, 2014, 2016-2019, 2021, 2022 Albert Astals Cid <aacid@kde.org>
|
|
|
a99760 |
// Copyright 2010, 2013 Pino Toscano <pino@kde.org>
|
|
|
a99760 |
// Copyright 2013 Adrian Johnson <ajohnson@redneon.com>
|
|
|
a99760 |
// Copyright 2014 Fabio D'Urso <fabiodurso@hotmail.it>
|
|
|
a99760 |
@@ -189,21 +189,31 @@ void Hints::readTables(BaseStream *str, Linearization *linearization, XRef *xref
|
|
|
a99760 |
char *p = &buf[0];
|
|
|
a99760 |
|
|
|
a99760 |
if (hintsOffset && hintsLength) {
|
|
|
a99760 |
- Stream *s = str->makeSubStream(hintsOffset, false, hintsLength, Object(objNull));
|
|
|
a99760 |
+ std::unique_ptr<Stream> s(str->makeSubStream(hintsOffset, false, hintsLength, Object(objNull)));
|
|
|
a99760 |
s->reset();
|
|
|
a99760 |
for (unsigned int i = 0; i < hintsLength; i++) {
|
|
|
a99760 |
- *p++ = s->getChar();
|
|
|
a99760 |
+ const int c = s->getChar();
|
|
|
a99760 |
+ if (unlikely(c == EOF)) {
|
|
|
a99760 |
+ error(errSyntaxWarning, -1, "Found EOF while reading hints");
|
|
|
a99760 |
+ ok = false;
|
|
|
a99760 |
+ return;
|
|
|
a99760 |
+ }
|
|
|
a99760 |
+ *p++ = c;
|
|
|
a99760 |
}
|
|
|
a99760 |
- delete s;
|
|
|
a99760 |
}
|
|
|
a99760 |
|
|
|
a99760 |
if (hintsOffset2 && hintsLength2) {
|
|
|
a99760 |
- Stream *s = str->makeSubStream(hintsOffset2, false, hintsLength2, Object(objNull));
|
|
|
a99760 |
+ std::unique_ptr<Stream> s(str->makeSubStream(hintsOffset2, false, hintsLength2, Object(objNull)));
|
|
|
a99760 |
s->reset();
|
|
|
a99760 |
for (unsigned int i = 0; i < hintsLength2; i++) {
|
|
|
a99760 |
- *p++ = s->getChar();
|
|
|
a99760 |
+ const int c = s->getChar();
|
|
|
a99760 |
+ if (unlikely(c == EOF)) {
|
|
|
a99760 |
+ error(errSyntaxWarning, -1, "Found EOF while reading hints2");
|
|
|
a99760 |
+ ok = false;
|
|
|
a99760 |
+ return;
|
|
|
a99760 |
+ }
|
|
|
a99760 |
+ *p++ = c;
|
|
|
a99760 |
}
|
|
|
a99760 |
- delete s;
|
|
|
a99760 |
}
|
|
|
a99760 |
|
|
|
a99760 |
MemStream *memStream = new MemStream(&buf[0], 0, bufLength, Object(objNull));
|