aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2017-07-29 00:02:39 +0200
committerJay Berkenbilt <ejb@ql.org>2017-07-29 00:03:30 +0200
commita94a729fee946947db7a056f02b326dfce681128 (patch)
tree51c82b4761a7f72754650f750aa18a8554adca0f /libqpdf
parentede1255a82665dd870451ac896bcef95a7830b57 (diff)
downloadqpdf-a94a729fee946947db7a056f02b326dfce681128.tar.zst
Explicitly check root dictionary type
Very badly corrupted files may not have a retrievable root dictionary. Handle that as a special case so that a more helpful error message can be provided.
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/QPDF.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc
index b5c1212c..4d5bf67f 100644
--- a/libqpdf/QPDF.cc
+++ b/libqpdf/QPDF.cc
@@ -2028,7 +2028,14 @@ QPDF::getTrailer()
QPDFObjectHandle
QPDF::getRoot()
{
- return this->trailer.getKey("/Root");
+ QPDFObjectHandle root = this->trailer.getKey("/Root");
+ if (! root.isDictionary())
+ {
+ throw QPDFExc(qpdf_e_damaged_pdf, file->getName(),
+ "", file->getLastOffset(),
+ "unable to find /Root dictionary");
+ }
+ return root;
}
void