Commit 4660e23262fd3606d0b9ef7db9bcc315783b16e3
Committed by
GitHub
Merge pull request #1128 from m-holger/reconstruct
Tighten checks for invalid indirect references during xref reconstru…
Showing
3 changed files
with
5 additions
and
1 deletions
libqpdf/QPDF.cc
| ... | ... | @@ -1195,6 +1195,10 @@ QPDF::insertFreeXrefEntry(QPDFObjGen og) |
| 1195 | 1195 | void |
| 1196 | 1196 | QPDF::insertReconstructedXrefEntry(int obj, qpdf_offset_t f1, int f2) |
| 1197 | 1197 | { |
| 1198 | + if (!(obj > 0 && 0 <= f2 && f2 < 65535)) { | |
| 1199 | + QTC::TC("qpdf", "QPDF xref overwrite invalid objgen"); | |
| 1200 | + return; | |
| 1201 | + } | |
| 1198 | 1202 | QPDFObjGen og(obj, f2); |
| 1199 | 1203 | if (!m->deleted_objects.count(obj)) { |
| 1200 | 1204 | // deleted_objects stores the uncompressed objects removed from the xref table at the start | ... | ... |
qpdf/qpdf.testcov
| ... | ... | @@ -105,6 +105,7 @@ QPDF_encryption xref stream from encrypted file 0 |
| 105 | 105 | QPDFJob unable to filter 0 |
| 106 | 106 | QUtil non-trivial UTF-16 0 |
| 107 | 107 | QPDF xref overwrite object 0 |
| 108 | +QPDF xref overwrite invalid objgen 0 | |
| 108 | 109 | QPDF decoding error warning 0 |
| 109 | 110 | qpdf-c called qpdf_init 0 |
| 110 | 111 | qpdf-c called qpdf_cleanup 0 | ... | ... |