sc/source/filter/xml/XMLTableHeaderFooterContext.cxx |   24 +++++++++++++------
 1 file changed, 17 insertions(+), 7 deletions(-)

New commits:
commit 3fbe7459d53396f84165ad364a07bce41a82d75d
Author:     Caolán McNamara <[email protected]>
AuthorDate: Fri Sep 12 10:55:41 2025 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Fri Sep 12 13:51:08 2025 +0200

    ofz#444495246 avoid timeout when fuzzing
    
    Change-Id: I2c1df68551300fa4b32cf20346b01d86bdcb85c8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190866
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/sc/source/filter/xml/XMLTableHeaderFooterContext.cxx 
b/sc/source/filter/xml/XMLTableHeaderFooterContext.cxx
index 71670335c59d..518df31b7c6a 100644
--- a/sc/source/filter/xml/XMLTableHeaderFooterContext.cxx
+++ b/sc/source/filter/xml/XMLTableHeaderFooterContext.cxx
@@ -24,6 +24,7 @@
 #include <xmloff/xmlimp.hxx>
 #include "XMLTableHeaderFooterContext.hxx"
 #include <xmloff/xmltoken.hxx>
+#include <comphelper/configuration.hxx>
 #include <comphelper/extract.hxx>
 #include <sal/log.hxx>
 
@@ -156,6 +157,19 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > 
XMLTableHeaderFooterCo
     return nullptr;
 }
 
+static void checkHeaderFooter(const uno::Reference<text::XText>& rText, bool 
bContainsContent)
+{
+    if (!bContainsContent)
+        rText->setString(u""_ustr);
+    else if (comphelper::IsFuzzing())
+    {
+        if (rText->getString().getLength() > 10000)
+        {
+            // discourage very long paragraphs for fuzzing performance
+            rText->setString(u""_ustr);
+        }
+    }
+}
 void XMLTableHeaderFooterContext::endFastElement(sal_Int32 )
 {
     if( GetImport().GetTextImport()->GetCursor().is() )
@@ -173,13 +187,9 @@ void XMLTableHeaderFooterContext::endFastElement(sal_Int32 
)
         GetImport().GetTextImport()->SetCursor(xOldTextCursor);
     if (xHeaderFooterContent.is())
     {
-        if (!bContainsLeft)
-            xHeaderFooterContent->getLeftText()->setString(u""_ustr);
-        if (!bContainsCenter)
-            xHeaderFooterContent->getCenterText()->setString(u""_ustr);
-        if (!bContainsRight)
-            xHeaderFooterContent->getRightText()->setString(u""_ustr);
-
+        checkHeaderFooter(xHeaderFooterContent->getLeftText(), bContainsLeft);
+        checkHeaderFooter(xHeaderFooterContent->getCenterText(), 
bContainsCenter);
+        checkHeaderFooter(xHeaderFooterContent->getRightText(), 
bContainsRight);
         xPropSet->setPropertyValue( sCont, uno::Any(xHeaderFooterContent) );
     }
 }

Reply via email to