[PATCH] Make sure regex doesn't stack overflow by limiting it
authorAlbert Astals Cid <aacid@kde.org>
Wed, 26 Mar 2025 10:26:32 +0000 (11:26 +0100)
committerSalvatore Bonaccorso <carnil@debian.org>
Sun, 12 Oct 2025 18:30:50 +0000 (20:30 +0200)
Happens with very long pdfsubver strings when compiled with
-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -flto=auto

Origin: 25.04.0

Gbp-Pq: Name CVE-2025-43718.patch

poppler/PDFDoc.cc

index f0dae9be7f56c92f2e82112eb85a5529dea64f46..118c4692d49b4f2fb5f1cf789e3af7de79585177 100644 (file)
@@ -14,7 +14,7 @@
 // under GPL version 2 or later
 //
 // Copyright (C) 2005, 2006, 2008 Brad Hards <bradh@frogmouth.net>
-// Copyright (C) 2005, 2007-2009, 2011-2024 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2005, 2007-2009, 2011-2025 Albert Astals Cid <aacid@kde.org>
 // Copyright (C) 2008 Julien Rebetez <julienr@svn.gnome.org>
 // Copyright (C) 2008, 2010 Pino Toscano <pino@kde.org>
 // Copyright (C) 2008, 2010, 2011 Carlos Garcia Campos <carlosgc@gnome.org>
@@ -479,7 +479,7 @@ static PDFSubtypePart pdfPartFromString(PDFSubtype subtype, const std::string &p
 
 static PDFSubtypeConformance pdfConformanceFromString(const std::string &pdfsubver)
 {
-    const std::regex regex("PDF/(?:A|X|VT|E|UA)-[[:digit:]]([[:alpha:]]+)");
+    const std::regex regex("PDF/(?:A|X|VT|E|UA)-[[:digit:]]([[:alpha:]]{1,3})");
     std::smatch match;
 
     // match contains the PDF conformance (A, B, G, N, P, PG or U)