diff options
author | Jay Berkenbilt <ejb@ql.org> | 2020-11-04 13:46:46 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2020-11-04 13:46:46 +0100 |
commit | 47f4ebcdac39256b084cdbb91ff04392fca4bb8d (patch) | |
tree | 6d629440a0c4f8a5b12ead41aa17f5401286b6b5 /libqpdf | |
parent | 3e5aaa299a1f6675b73b56061b44ded4216ad34d (diff) | |
download | qpdf-47f4ebcdac39256b084cdbb91ff04392fca4bb8d.tar.zst |
Ignore unused field in xref entry, avoiding range error (fixes #482)
Diffstat (limited to 'libqpdf')
-rw-r--r-- | libqpdf/QPDF.cc | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index 62ad926c..a233f05e 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -425,7 +425,20 @@ QPDF::parse(char const* password) throw QPDFExc(qpdf_e_damaged_pdf, this->m->file->getName(), "", 0, "can't find startxref"); } - read_xref(xref_offset); + try + { + read_xref(xref_offset); + } + catch (QPDFExc&) + { + throw; + } + catch (std::exception& e) + { + throw QPDFExc(qpdf_e_damaged_pdf, this->m->file->getName(), "", 0, + std::string("error reading xref: ") + e.what()); + + } } catch (QPDFExc& e) { @@ -1250,6 +1263,14 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle& xref_obj) // This is needed by checkLinearization() this->m->first_xref_item_offset = xref_offset; } + if (fields[0] == 0) + { + // Ignore fields[2], which we don't care about in this + // case. This works around the issue of some PDF files + // that put invalid values, like -1, here for deleted + // objects. + fields[2] = 0; + } insertXrefEntry(obj, toI(fields[0]), fields[1], toI(fields[2])); } |