Add another pixel test for incorrect cross reference stream handling
Add another handcrafted PDF, where yet another copy of rectangles.pdf
has been modified:
1) Add some fake objects to confuse CPDF_Parser::RebuildCrossRef().
Otherwise, the cross reference table reconstruction finds all the
objects and masks the buggy behavior.
2) Update object indices to account for (1).
3) Append a cross reference stream update that adds no new information.
Bug: pdfium:2123
Change-Id: I4a06bc8db0aa2b7ae4df527030a6fcb69f429ca1
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/116273
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
diff --git a/testing/SUPPRESSIONS b/testing/SUPPRESSIONS
index 96c84d12..77d15a8 100644
--- a/testing/SUPPRESSIONS
+++ b/testing/SUPPRESSIONS
@@ -659,6 +659,9 @@
# TODO(pdfium:2001): Remove after associated bug is fixed
bug_2001.pdf * * * *
+# TODO(pdfium:2123): Remove after associated bug is fixed
+bug_2123.pdf * * * *
+
# TODO(chromium:237527): Remove after associated bug is fixed
bug_237527_1.in * * * *
diff --git a/testing/resources/pixel/bug_2123.pdf b/testing/resources/pixel/bug_2123.pdf
new file mode 100644
index 0000000..e3623b2
--- /dev/null
+++ b/testing/resources/pixel/bug_2123.pdf
@@ -0,0 +1,90 @@
+%PDF-1.7
+% ò¤ô
+1 0 obj <<
+ /Type /Catalog
+ /Pages 2 0 R
+>>
+endobj
+% Not actually used. This is just bait for the parser code that reconstructs
+% damaged PDFs.
+2 0 obj <<
+ /Type /Pages
+ /MediaBox [0 0 200 350]
+ /Count 1
+ /Kids [3 0 R]
+>>
+endobj
+% Actually used.
+2 0 obj <<
+ /Type /Pages
+ /MediaBox [0 0 200 300]
+ /Count 1
+ /Kids [3 0 R]
+>>
+endobj
+% Not actually used. This is just bait for the parser code that reconstructs
+% damaged PDFs.
+2 0 obj <<
+ /Type /Pages
+ /MediaBox [0 0 200 400]
+ /Count 1
+ /Kids [3 0 R]
+>>
+endobj
+3 0 obj <<
+ /Type /Page
+ /Parent 2 0 R
+ /Contents 4 0 R
+>>
+endobj
+4 0 obj <<
+ /Length 188
+>>
+stream
+q
+0 0 0 rg
+0 290 10 10 re B*
+10 150 50 30 re B*
+0 0 1 rg
+190 290 10 10 re B*
+70 232 50 30 re B*
+0 1 0 rg
+190 0 10 10 re B*
+130 150 50 30 re B*
+1 0 0 rg
+0 0 10 10 re B*
+70 67 50 30 re B*
+Q
+endstream
+endobj
+xref
+0 5
+0000000000 65535 f
+0000000015 00000 n
+0000000267 00000 n
+0000000538 00000 n
+0000000607 00000 n
+trailer <<
+ /Root 1 0 R
+ /Size 5
+>>
+startxref
+847
+%%EOF
+5 0 obj <<
+ /Type /XRef
+ /Filter /ASCIIHexDecode
+ /Index [0 1]
+ /Length 13
+ /Prev 847
+ /Root 1 0 R
+ /Size 5
+ /W [1 2 2]
+>>
+stream
+00 0000 FFFF
+endstream
+endobj
+startxref
+1014
+%%EOF
diff --git a/testing/resources/pixel/bug_2123_expected.pdf.0.png b/testing/resources/pixel/bug_2123_expected.pdf.0.png
new file mode 100644
index 0000000..ee652fa
--- /dev/null
+++ b/testing/resources/pixel/bug_2123_expected.pdf.0.png
Binary files differ
diff --git a/testing/resources/pixel/bug_2123_expected_gdi.pdf.0.png b/testing/resources/pixel/bug_2123_expected_gdi.pdf.0.png
new file mode 100644
index 0000000..72da0cd
--- /dev/null
+++ b/testing/resources/pixel/bug_2123_expected_gdi.pdf.0.png
Binary files differ
diff --git a/testing/resources/pixel/bug_2123_expected_skia.pdf.0.png b/testing/resources/pixel/bug_2123_expected_skia.pdf.0.png
new file mode 100644
index 0000000..8a6b8ed
--- /dev/null
+++ b/testing/resources/pixel/bug_2123_expected_skia.pdf.0.png
Binary files differ