poppler/poppler-20.11.0-bad-generation.patch

36 lines
1.2 KiB
Diff
Raw Normal View History

From 4f478daa6a9734b8f269a6586bdce2909844bb6f Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <aacid@kde.org>
Date: Wed, 23 Dec 2020 23:52:58 +0100
Subject: Fix opening files by some generators that are a bit broken
But Adobe opens it and it's easy to fix
diff --git a/poppler/XRef.cc b/poppler/XRef.cc
index 66d3f04a..c36c747a 100644
--- a/poppler/XRef.cc
+++ b/poppler/XRef.cc
@@ -45,6 +45,7 @@
#include <cctype>
#include <climits>
#include <cfloat>
+#include <limits>
#include "goo/gfile.h"
#include "goo/gmem.h"
#include "Object.h"
@@ -793,8 +794,13 @@ bool XRef::readXRefStreamSection(Stream *xrefStr, const int *w, int first, int n
gen = (gen << 8) + c;
}
if (gen > INT_MAX) {
- error(errSyntaxError, -1, "Gen inside xref table too large (bigger than INT_MAX)");
- return false;
+ if (i == 0 && gen == std::numeric_limits<uint32_t>::max()) {
+ // workaround broken generators
+ gen = 65535;
+ } else {
+ error(errSyntaxError, -1, "Gen inside xref table too large (bigger than INT_MAX)");
+ return false;
+ }
}
if (entries[i].offset == -1) {
switch (type) {