summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Watts <Robin.Watts@artifex.com>2025-04-16 13:40:12 +0100
committerRobin Watts <Robin.Watts@artifex.com>2025-04-16 15:00:53 +0100
commit68796e06e9d71c895996823880a831a4d67c8cdb (patch)
tree615aff025dbc9f87871a08a6817995c754181ef6
parent14725d251f5dbe00d759c2219692c90708f4c57b (diff)
Bug 708456: Loosen test for PDF trailer Size being correct.
Allow for it being off by 1 in more cases (not just in the case where it's the XRef object that isn't being accounted for). Maybe we shouldn't repair on broken values at all, and just live with it?
-rw-r--r--source/pdf/pdf-xref.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c
index 11f180311..56e28e5fc 100644
--- a/source/pdf/pdf-xref.c
+++ b/source/pdf/pdf-xref.c
@@ -1635,7 +1635,17 @@ pdf_read_xref_sections(fz_context *ctx, pdf_document *doc, int64_t ofs, int read
size = pdf_dict_get_int(ctx, pdf_trailer(ctx, doc), PDF_NAME(Size));
xref_len = pdf_xref_len(ctx, doc);
if (xref_len > size)
- fz_throw(ctx, FZ_ERROR_FORMAT, "incorrect number of xref entries in trailer, repairing");
+ {
+ if (xref_len == size+1)
+ {
+ /* Bug 708456 && Bug 708176. Allow for (sadly, quite common
+ * PDF generators that can't get size right). */
+ fz_warn(ctx, "Trailer Size is off-by-one. Ignoring.");
+ pdf_dict_put_int(ctx, pdf_trailer(ctx, doc), PDF_NAME(Size), size+1);
+ }
+ else
+ fz_throw(ctx, FZ_ERROR_FORMAT, "incorrect number of xref entries in trailer, repairing");
+ }
}
fz_always(ctx)
{