Parse generation numbers for normal objects in cross-reference streams

When parsing objects in cross-reference streams, use the generation
number from the stream, instead of always using 0. Then PDFs that rely
on appended sections having higher generation numbers can render
correctly. Unsuppress the bug_349972030.pdf pixel test, which is one
such PDF.

Bug: 349972030
Change-Id: Ie03a378c6b7f15a4b6446902c1e3fa5c2e159aca
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/121234
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Tom Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp
index 3423c6a..28dcb14 100644
--- a/core/fpdfapi/parser/cpdf_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_parser.cpp
@@ -913,8 +913,10 @@
 
   if (type == ObjectType::kNormal) {
     const uint32_t offset = GetSecondXRefStreamEntry(entry_span, field_widths);
-    if (pdfium::IsValueInRangeForNumericType<FX_FILESIZE>(offset)) {
-      m_CrossRefTable->AddNormal(obj_num, 0, /*is_object_stream=*/false,
+    const uint32_t gen_num = GetThirdXRefStreamEntry(entry_span, field_widths);
+    if (pdfium::IsValueInRangeForNumericType<FX_FILESIZE>(offset) &&
+        pdfium::IsValueInRangeForNumericType<uint16_t>(gen_num)) {
+      m_CrossRefTable->AddNormal(obj_num, gen_num, /*is_object_stream=*/false,
                                  offset);
     }
     return;
diff --git a/testing/SUPPRESSIONS b/testing/SUPPRESSIONS
index 2dcda6d..1d66c26 100644
--- a/testing/SUPPRESSIONS
+++ b/testing/SUPPRESSIONS
@@ -668,9 +668,6 @@
 # TODO(crbug.com/346766787): Remove after associated bug is fixed
 bug_346766787.in * * * *
 
-# TODO(crbug.com/349972030): Remove after associated bug is fixed
-bug_349972030.pdf * * * *
-
 # TODO(chromium:451366): Remove after associated bug is fixed
 bug_451366.in * * * agg