2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-11-08 14:21:06 +00:00
Commit Graph

430 Commits

Author SHA1 Message Date
m-holger
9ce18e41f4
Merge pull request #979 from m-holger/const
In FUTURE make various QPDFObjectHandle methods const
2024-07-19 10:50:08 +01:00
m-holger
fe1fffe8db Change QPDF max_warnings into a hard limit
Throw damagedFile if max_warnings is exceeded. Change qpdf_fuzzer warnings limit to
limit to 500.
2024-07-18 16:50:08 +01:00
m-holger
186fca6d8d Add further sanity checks to QPDF::reconstruct_xref
Run getAllPages as sanity check and throw an exception if too many
warnings are generated or no pages are found.
2024-07-13 14:51:14 +01:00
m-holger
e914bbbbbc Add further sanity check to QPDF::reconstruct_xref
If reconstruct_xref generates more than 1000 warnings give up because the
file is so severely damaged that there is very little point continuing.
2024-07-11 13:25:07 +01:00
m-holger
2e378d920d Add additional sanity check during xref reconstruction
Check that xref table is not empty after recovery. Empty xref tables
disable other sanity checks.
2024-07-09 17:01:44 +01:00
m-holger
7445e0ac1e Fix QPDF::setSuppressWarnings 2024-07-09 16:38:02 +01:00
m-holger
c1cd3ec8a0 In QPDF::processXRefIndex check number of objects in subsection is > 0
Fixes oss-fuzz 70055
2024-07-06 16:09:50 +01:00
m-holger
f0ded6bca8 Add test case for self-referential object streams
Previous test case was lost in #1221. Test file was created from
object-stream.pdf by adding a reference to itself into object stream 1 0.
2024-07-04 20:40:47 +01:00
Jay Berkenbilt
598268f6ad Add setMaxWarnings rather than using conditional compilation 2024-07-03 15:44:44 +01:00
Jay Berkenbilt
65bd8bc57d Add DCT decompression config methods in favor of compile-time changes
As a rule, we should avoid conditional compilation is it always causes
code paths that are sometimes not even seen lexically by the compiler.
Also, we want the actual code being fuzzed to be as close as possible
to the real code. Conditional compilation is suitable to handle
underlying system differences.

Instead, favor configuration using callbacks or other methods that can
be triggered in the places where they need to be exercised.
2024-07-03 15:43:38 +01:00
m-holger
a367e56afc In QPDF::resolveObjectsInStream avoid creating xref table entries
Invalid entries are created when objects in the stream do not have
an existing xref entry.
2024-07-02 01:16:23 +01:00
m-holger
6d640c569a Add additional object id sanity checks
Ensure objects with impossibly large ids are ignored.
2024-07-02 01:16:23 +01:00
m-holger
42c511198b Suppress excessive warnings while fuzzing
Add extra fuzz test case and amend memory limit for Pl_DCT.
2024-07-02 01:16:23 +01:00
m-holger
8ae3ef28ac Fix #1170
In QPDF::read_xrefEntry add buffer overflow test for first eol character.
Overlong f1 or f2 entries consisting only of zeros could cause a buffer
overflow.

Add fuzz testcase 69913.
2024-06-27 08:17:58 +01:00
m-holger
3d569e2171
Merge pull request #1221 from m-holger/fuzz
Refine handling of severely damaged files
2024-06-27 01:18:37 +01:00
m-holger
4a8c821e3e In QPDF::reconstruct_xref add sanity check for object ids 2024-06-25 15:46:47 +01:00
m-holger
e62973d277 In QPDF check for page tree after reading xref table
Also add new fuzz test case.
2024-06-25 15:18:54 +01:00
m-holger
295f62f041
Merge pull request #1170 from m-holger/readxref
Refactor QPDF::parse_xrefEntry
2024-06-19 20:08:44 +01:00
m-holger
9641626cae Refactor resolving of objects 2024-06-19 10:34:01 +01:00
m-holger
ce5b864c53
Merge pull request #1201 from m-holger/xref_stream
QPDF::processXRefStream
2024-06-18 20:21:39 +01:00
m-holger
2b0c2da720 Refactor QPDF::processXRefStream
Change the processed Index array to a vector of <first object, number of
entries> pairs.
2024-05-22 18:53:30 +01:00
m-holger
7477ea7828 Add new private method QPDF::processXRefSize 2024-05-22 17:07:42 +01:00
m-holger
f74b28f0d1 Add new private method QPDF::processXRefW 2024-05-22 17:07:37 +01:00
m-holger
0186d60dcf Add new private method QPDF::processXRefIndex 2024-05-22 17:07:28 +01:00
m-holger
7aa5027bf8 Refactor QPDF::procesXRefStream
Add closure damaged to create damagedPDF exceptions.
2024-05-22 17:07:16 +01:00
m-holger
1737902a5e Refactor QPDF::processXRefStream
Tune processing of subsections.
2024-05-21 20:31:52 +01:00
m-holger
f1c774f13f Refactor QPDF::processXRefStream
Tune pointer arithmetic.
2024-05-21 20:31:40 +01:00
m-holger
8cd50e0e3e Fix QPDF::tableSize
Apply temporary fix to deal with fuzz case 68915.

(Error is an integer overflow which would immediately cause a runtime error
as a result of a call to QInitCQIntC::to_size.)
2024-05-21 12:50:19 +01:00
m-holger
e85b98b7e8 Guard against object id == std::numeric_limits<int> in QPDF::insertReconstructedXrefEntry 2024-04-30 12:38:02 +01:00
m-holger
972cbf103d In QPDF::processXRefStream avoid inserting objed id 0 into the xref table 2024-04-30 10:38:59 +01:00
m-holger
0df0d00c58 Add method QPDF::Writer::getCompressibleObjSet
Create set without creation of an intermediate vector.
2024-03-08 10:20:12 +00:00
m-holger
ae00ee6119 Replace QPDF::Writer::getObjectStreamData with getXRefTable 2024-03-08 10:10:31 +00:00
m-holger
8791b5f8d0 In QPDFWriter replace map obj_renumber with a new object table obj 2024-03-08 09:36:22 +00:00
m-holger
72bd486337 Refactor QPDF::parse_xrefEntry
Move reading of the entry from read_xrefTable to parse_xrefEntry.

Split parse_xrefEntry into two new methods read_xrefEntry and
read_bad_xrefEntry. read_xrefEntry is optimised for reading
correct entries. To handle incorrect entries it calls read_bad_xrefEntry,
which is largely unchanged from parse_xrefEntry.
2024-03-07 15:33:27 +00:00
Jay Berkenbilt
7caa9ddf5a Format code 2024-02-04 16:12:01 -05:00
m-holger
f0343565ed Tighten checks for invalid indirect references during xref reconstruction 2024-01-17 14:11:57 +00:00
m-holger
6e3b7982db Fix incorrect handling of invalid negative object ids
Fix two errors introduced in #1110 and #1112. Since
#1110, encountering the invalid indirect reference #1110
-2147483648 n R produces an integer underflow which, if
 undetected, immediately trigger a logic error. Since
 #1112, object -1 0 R may be incorrectly identified as
 an earlier generation of itself and deleted,
 invalidating a live iterator.
2024-01-17 10:39:06 +00:00
m-holger
e28625144d Tweak QPDF::getCompressibleObjGens 2024-01-08 10:55:51 -05:00
Jay Berkenbilt
adb866efd3 Fix error from older gcc versions 2024-01-08 10:55:51 -05:00
m-holger
8715d6a693 Tweak QPDF::replaceObject 2024-01-08 11:54:33 +00:00
m-holger
5641832e54 Tweak QPDF::read_xref 2024-01-08 11:43:57 +00:00
Jay Berkenbilt
07f6c635a9 Bug fix: treat old generations of reused objects as null 2024-01-07 17:16:14 -05:00
Jay Berkenbilt
df61f3a6c6 Improve getCompressibleObjGens fix to handle gen > 0 2024-01-07 15:22:04 -05:00
m-holger
ba477e0b33 Tune QPDF::getCompressibleObjGens
Change set visited to std::vector<bool>
2024-01-07 17:39:40 +00:00
m-holger
6195499598 Tune QPDF::getCompressibleObjGens
Swap front and back, and change queue from list to vector
2024-01-07 16:39:03 +00:00
Jay Berkenbilt
55b0024899 Format code 2024-01-06 17:23:45 -05:00
Jay Berkenbilt
7b3fff15a9 QPDF.cc: remove unused includes 2024-01-06 17:19:16 -05:00
Jay Berkenbilt
2994f9cf4c Attempt to find xref streams during recovery (fixes #1103) 2024-01-06 16:51:03 -05:00
Jay Berkenbilt
7c0fdf8510 Format code, bump clang-format version to 18 2023-12-22 21:45:10 -05:00
m-holger
ddad5ad53e In QPDF::pipeStreamData use unique_ptr as heap 2023-11-26 13:06:12 +00:00