mirror of
https://github.com/qpdf/qpdf.git
synced 2025-02-08 22:58:25 +00:00
Fix infinite loop in QPDFWriter (fixes #143)
This commit is contained in:
parent
36b3fe5af7
commit
8249a26d69
@ -1054,6 +1054,9 @@ QPDFWriter::enqueueObject(QPDFObjectHandle object)
|
|||||||
// here. Instead, enqueue the object stream. Object
|
// here. Instead, enqueue the object stream. Object
|
||||||
// streams always have generation 0.
|
// streams always have generation 0.
|
||||||
int stream_id = this->object_to_object_stream[og];
|
int stream_id = this->object_to_object_stream[og];
|
||||||
|
// Detect loops by storing invalid object ID 0, which
|
||||||
|
// will get overwritten later.
|
||||||
|
obj_renumber[og] = 0;
|
||||||
enqueueObject(this->pdf.getObjectByID(stream_id, 0));
|
enqueueObject(this->pdf.getObjectByID(stream_id, 0));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1079,6 +1082,12 @@ QPDFWriter::enqueueObject(QPDFObjectHandle object)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (obj_renumber[og] == 0)
|
||||||
|
{
|
||||||
|
// This can happen if a specially constructed file
|
||||||
|
// indicates that an object stream is inside itself.
|
||||||
|
QTC::TC("qpdf", "QPDFWriter ignore self-referential object stream");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (object.isArray())
|
else if (object.isArray())
|
||||||
{
|
{
|
||||||
|
@ -294,3 +294,4 @@ QPDF ignore first extra space in xref entry 0
|
|||||||
QPDF ignore second extra space in xref entry 0
|
QPDF ignore second extra space in xref entry 0
|
||||||
QPDF ignore length error xref entry 0
|
QPDF ignore length error xref entry 0
|
||||||
QPDF_encryption pad short parameter 0
|
QPDF_encryption pad short parameter 0
|
||||||
|
QPDFWriter ignore self-referential object stream 0
|
||||||
|
@ -220,6 +220,7 @@ my @bug_tests = (
|
|||||||
["106", "zlib data error", 3],
|
["106", "zlib data error", 3],
|
||||||
["141a", "/W entry size 0", 2],
|
["141a", "/W entry size 0", 2],
|
||||||
["141b", "/W entry size 0", 2],
|
["141b", "/W entry size 0", 2],
|
||||||
|
["143", "self-referential ostream", 3],
|
||||||
);
|
);
|
||||||
$n_tests += scalar(@bug_tests);
|
$n_tests += scalar(@bug_tests);
|
||||||
foreach my $d (@bug_tests)
|
foreach my $d (@bug_tests)
|
||||||
|
19
qpdf/qtest/qpdf/issue-143.out
Normal file
19
qpdf/qtest/qpdf/issue-143.out
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
WARNING: issue-143.pdf: can't find PDF header
|
||||||
|
WARNING: issue-143.pdf (xref stream: object 3 0, file position 654): stream keyword not followed by proper line terminator
|
||||||
|
WARNING: issue-143.pdf (xref stream: object 3 0, file position 607): stream dictionary lacks /Length key
|
||||||
|
WARNING: issue-143.pdf (xref stream: object 3 0, file position 654): attempting to recover stream length
|
||||||
|
WARNING: issue-143.pdf (xref stream: object 3 0, file position 654): recovered stream length: 36
|
||||||
|
WARNING: issue-143.pdf (xref stream: object 3 0, file position 694): expected endobj
|
||||||
|
WARNING: issue-143.pdf: file is damaged
|
||||||
|
WARNING: issue-143.pdf (object 1 0, file position 48): expected n n obj
|
||||||
|
WARNING: issue-143.pdf: Attempting to reconstruct cross-reference table
|
||||||
|
WARNING: issue-143.pdf (file position 24): expected dictionary key but found non-name object; inserting key /QPDFFake1
|
||||||
|
WARNING: issue-143.pdf (file position 24): expected dictionary key but found non-name object; inserting key /QPDFFake2
|
||||||
|
WARNING: issue-143.pdf (file position 24): expected dictionary key but found non-name object; inserting key /QPDFFake3
|
||||||
|
WARNING: issue-143.pdf (file position 24): expected dictionary key but found non-name object; inserting key /QPDFFake4
|
||||||
|
WARNING: issue-143.pdf (object 1 0, file position 21): stream dictionary lacks /Length key
|
||||||
|
WARNING: issue-143.pdf (object 1 0, file position 84): attempting to recover stream length
|
||||||
|
WARNING: issue-143.pdf (object 1 0, file position 84): recovered stream length: 606
|
||||||
|
WARNING: issue-143.pdf (object 1 0, file position 694): expected endobj
|
||||||
|
WARNING: object stream 1 (file position 33): expected dictionary key but found non-name object; inserting key /QPDFFake1
|
||||||
|
qpdf: operation succeeded with warnings; resulting file may have some problems
|
BIN
qpdf/qtest/qpdf/issue-143.pdf
Normal file
BIN
qpdf/qtest/qpdf/issue-143.pdf
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user