2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-11-05 21:07:50 +00:00

Merge pull request #1200 from m-holger/fuzz

Fix QPDF::tableSize
This commit is contained in:
Jay Berkenbilt 2024-05-24 08:52:42 -04:00 committed by GitHub
commit 2eefa580aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2391,6 +2391,13 @@ QPDF::tableSize()
// objects.
auto max_xref = m->xref_table.size() ? m->xref_table.crbegin()->first.getObj() : 0;
auto max_obj = m->obj_cache.size() ? m->obj_cache.crbegin()->first.getObj() : 0;
auto max_id = std::numeric_limits<int>::max() - 1;
if (max_obj >= max_id || max_xref >= max_id) {
// Temporary fix. Long-term solution is
// - QPDFObjGen to enforce objgens are valid and sensible
// - xref table and obj cache to protect against insertion of impossibly large obj ids
stopOnError("Impossibly large object id encountered.");
}
if (max_obj < 1.1 * std::max(toI(m->obj_cache.size()), max_xref)) {
return toS(++max_obj);
}