diff options
author | Jay Berkenbilt <ejb@ql.org> | 2017-07-29 00:02:39 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2017-07-29 00:03:30 +0200 |
commit | a94a729fee946947db7a056f02b326dfce681128 (patch) | |
tree | 51c82b4761a7f72754650f750aa18a8554adca0f /libqpdf/QPDF.cc | |
parent | ede1255a82665dd870451ac896bcef95a7830b57 (diff) | |
download | qpdf-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/QPDF.cc')
-rw-r--r-- | libqpdf/QPDF.cc | 9 |
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 |