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
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
m-holger
0dee397075
In QPDF::pipeStreamData read buffer in a single read
2023-11-26 12:26:57 +00:00
Jay Berkenbilt
98014ec98a
Fix error with stream recovery ( fixes #1042 )
2023-10-07 13:29:10 -04:00
m-holger
fb504ce913
Fix #1028
2023-09-05 17:22:34 +01:00
Jay Berkenbilt
bfbd97b938
Spell check
2023-09-03 14:07:30 -04:00
m-holger
b0c3ea2bb6
Refactor test for /Pages object in QPDF::copyForeignObject
...
Test for missing object before accessing obj_copier.object_map.
2023-09-03 13:41:11 +01:00
m-holger
ac32dbc313
Reserve foreign /Page objects in QPDF::copyForeignObject
...
Ensure that links to foreign pages are not broken provided that the page is
subsequently copied.
2023-08-25 14:06:42 +01:00
m-holger
ad73bbcd90
Change QPDF::reserveObjects to reserve indirect nulls to reserve foreign objects
2023-08-25 13:30:55 +01:00
m-holger
52539544c4
Modify QPDF::replaceReserved to allow replacing indirect nulls
2023-08-25 12:37:24 +01:00