File poppler-CVE-2025-52886.patch of Package poppler.40038
From ac36affcc8486de38e8905a8d6547a3464ff46e5 Mon Sep 17 00:00:00 2001
From: Sune Vuorela <sune@vuorela.dk>
Date: Tue, 3 Jun 2025 00:35:19 +0200
Subject: [PATCH] Limit ammount of annots per document/page
---
poppler/Annot.cc | 4 ++++
poppler/Page.cc | 16 ++++++++++++++++
2 files changed, 20 insertions(+)
Index: poppler-0.43.0/poppler/Annot.cc
===================================================================
--- poppler-0.43.0.orig/poppler/Annot.cc
+++ poppler-0.43.0/poppler/Annot.cc
@@ -1633,6 +1633,10 @@ void Annot::removeReferencedObjects() {
}
void Annot::incRefCnt() {
+ if (refCnt > 100000) {
+ error(errSyntaxError, -1, "Annotations likely malformed. Too many references. Stopping processing annots on page {0:d}", page);
+ return;
+ }
annotLocker();
refCnt++;
}
Index: poppler-0.43.0/poppler/Page.cc
===================================================================
--- poppler-0.43.0.orig/poppler/Page.cc
+++ poppler-0.43.0/poppler/Page.cc
@@ -310,6 +310,24 @@ Page::Page(PDFDoc *docA, int numA, Dict
goto err2;
}
+ if (annotsObj.isArray() && annotsObj.arrayGetLength() > 10000) {
+ error(errSyntaxError, -1, "Page annotations object (page {0:d}) is likely malformed. Too big: ({1:d})", num, annotsObj.arrayGetLength());
+ goto err2;
+ }
+ if (annotsObj.isRef()) {
+ Object resolvedObj;
+ getAnnots(&resolvedObj);
+
+ if (resolvedObj.isArray() && resolvedObj.arrayGetLength() > 10000) {
+ error(errSyntaxError, -1, "Page annotations object (page {0:d}) is likely malformed. Too big: ({1:d})", num, resolvedObj.arrayGetLength());
+ goto err2;
+ }
+ if (!resolvedObj.isArray() && !resolvedObj.isNull()) {
+ error(errSyntaxError, -1, "Page annotations object (page {0:d}) is wrong type ({1:s})", num, resolvedObj.getTypeName());
+ goto err2;
+ }
+ }
+
// contents
pageDict->lookupNF("Contents", &contents);
if (!(contents.isRef() || contents.isArray() ||