2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 10:58:58 +00:00

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.
This commit is contained in:
m-holger 2024-07-04 20:40:47 +01:00
parent edf3509b78
commit f0ded6bca8
7 changed files with 21 additions and 1 deletions

View File

@ -17,6 +17,11 @@
* Add static option to Pl_DCT to control whether decompression of * Add static option to Pl_DCT to control whether decompression of
corrupt JPEG data is attempted. corrupt JPEG data is attempted.
2024-07-01 M Holger <m.holger@qpdf.org>
* Bug fix: certain invalid object streams caused the insertion of
invalid entries into in the xref table.
2024-06-29 M Holger <m.holger@qpdf.org> 2024-06-29 M Holger <m.holger@qpdf.org>
* Bug fix: in QPDFOutlineObjectHelper detect loops in the list of * Bug fix: in QPDFOutlineObjectHelper detect loops in the list of

View File

@ -1938,6 +1938,7 @@ QPDF::resolveObjectsInStream(int obj_stream_number)
continue; continue;
} }
if (num == obj_stream_number) { if (num == obj_stream_number) {
QTC::TC("qpdf", "QPDF ignore self-referential object stream");
warn(damagedPDF( warn(damagedPDF(
input, input,
m->last_object_description, m->last_object_description,

View File

@ -4,6 +4,7 @@ QPDF err wrong objid/generation 0
QPDF check objid 1 QPDF check objid 1
QPDF check generation 1 QPDF check generation 1
QPDF check obj 1 QPDF check obj 1
QPDF ignore self-referential object stream 0
QPDF hint table length indirect 0 QPDF hint table length indirect 0
QPDF hint table length direct 0 QPDF hint table length direct 0
QPDF P absent in lindict 0 QPDF P absent in lindict 0

View File

@ -16,7 +16,7 @@ cleanup();
my $td = new TestDriver('object-stream'); my $td = new TestDriver('object-stream');
my $n_tests = 7 + (36 * 4) + (12 * 2); my $n_tests = 9 + (36 * 4) + (12 * 2);
my $n_compare_pdfs = 36; my $n_compare_pdfs = 36;
for (my $n = 16; $n <= 19; ++$n) for (my $n = 16; $n <= 19; ++$n)
@ -107,5 +107,16 @@ $td->runtest("check file",
{$td->FILE => "a.pdf"}, {$td->FILE => "a.pdf"},
{$td->FILE => "recover-xref-stream-recovered.pdf"}); {$td->FILE => "recover-xref-stream-recovered.pdf"});
# Self-referential object stream
$td->runtest("self-referential object stream",
{$td->COMMAND => "qpdf --static-id --qdf" .
" object-stream-self-ref.pdf a.pdf"},
{$td->FILE => "object-stream-self-ref.out", $td->EXIT_STATUS => 3},
$td->NORMALIZE_NEWLINES);
$td->runtest("check file",
{$td->FILE => "a.pdf"},
{$td->FILE => "object-stream-self-ref.out.pdf"});
cleanup(); cleanup();
$td->report(calc_ntests($n_tests, $n_compare_pdfs)); $td->report(calc_ntests($n_tests, $n_compare_pdfs));

View File

@ -0,0 +1,2 @@
WARNING: object-stream-self-ref.pdf object stream 1 (object 1 0, offset 2): object stream claims to contain itself
qpdf: operation succeeded with warnings; resulting file may have some problems

Binary file not shown.

Binary file not shown.