This is an automated email from the ASF dual-hosted git repository.

centic9 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi.git

commit 6decd3b4df67bcb4c7716286c7c5b002d35e2f56
Author: Dominik Stadler <[email protected]>
AuthorDate: Thu Oct 22 12:10:54 2026 +0200

    Add dedicated fuzzer for XSSFBEventBasedExcelExtractor
    
    To try to cover this area some more as the
    general text-extraction does not reach this
    area currently
---
 poi-fuzz/README.md                                 |  6 +++
 .../main/java/org/apache/poi/fuzz/POIFuzzer.java   |  2 +
 .../java/org/apache/poi/fuzz/POIXSSFBFuzzer.java   | 63 ++++++++++++++++++++++
 3 files changed, 71 insertions(+)

diff --git a/poi-fuzz/README.md b/poi-fuzz/README.md
index 9de802fcf7..d4779aa05f 100644
--- a/poi-fuzz/README.md
+++ b/poi-fuzz/README.md
@@ -101,6 +101,12 @@ or allows to run it in a container-based infrastructure.
     cp corpus/spreadsheet/* corpus/integration/*.xlsx corpusXSSF/
     ../gradlew shadowJar && ./jazzer --cp=build/libs/poi-fuzz-6.0.0-all.jar 
"--instrumentation_includes=org.apache.poi.**:org.apache.xmlbeans.**" 
--target_class=org.apache.poi.fuzz.POIXSSFFuzzer -rss_limit_mb=2560 corpusXSSF
 
+## XSSFB
+
+    mkdir corpusXSSFB
+    cp corpus/spreadsheet/*.xlsb corpusXSSFB/
+    ../gradlew shadowJar && ./jazzer --cp=build/libs/poi-fuzz-6.0.0-all.jar 
"--instrumentation_includes=org.apache.poi.**:org.apache.xmlbeans.**" 
--target_class=org.apache.poi.fuzz.POIXSSFBFuzzer -rss_limit_mb=2560 corpusXSSFB
+
 ## XLSX2CSV
 
 Can re-use XSSF-corpus as the same files are processed here
diff --git a/poi-fuzz/src/main/java/org/apache/poi/fuzz/POIFuzzer.java 
b/poi-fuzz/src/main/java/org/apache/poi/fuzz/POIFuzzer.java
index 646cd27485..6bb3773a4e 100644
--- a/poi-fuzz/src/main/java/org/apache/poi/fuzz/POIFuzzer.java
+++ b/poi-fuzz/src/main/java/org/apache/poi/fuzz/POIFuzzer.java
@@ -90,6 +90,8 @@ public class POIFuzzer {
 
                POIXSSFFuzzer.fuzzerTestOneInput(input);
 
+               POIXSSFBFuzzer.fuzzerTestOneInput(input);
+
                POIXWPFFuzzer.fuzzerTestOneInput(input);
        }
 
diff --git a/poi-fuzz/src/main/java/org/apache/poi/fuzz/POIXSSFBFuzzer.java 
b/poi-fuzz/src/main/java/org/apache/poi/fuzz/POIXSSFBFuzzer.java
new file mode 100644
index 0000000000..89d8fccc1d
--- /dev/null
+++ b/poi-fuzz/src/main/java/org/apache/poi/fuzz/POIXSSFBFuzzer.java
@@ -0,0 +1,63 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.fuzz;
+
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.apache.poi.ooxml.POIXMLException;
+import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
+import org.apache.poi.openxml4j.opc.OPCPackage;
+import org.apache.poi.util.RecordFormatException;
+import org.apache.poi.xssf.binary.XSSFBParseException;
+import org.apache.poi.xssf.extractor.XSSFBEventBasedExcelExtractor;
+import org.apache.xmlbeans.XmlException;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+public class POIXSSFBFuzzer {
+       public static void fuzzerInitialize() {
+               POIFuzzer.adjustLimits();
+       }
+
+       public static void fuzzerTestOneInput(byte[] input) {
+               if (input.length == 0) {
+                       return;
+               }
+
+               try (OPCPackage pkg = OPCPackage.open(new 
ByteArrayInputStream(input), true)) {
+                       XSSFBEventBasedExcelExtractor ex = new 
XSSFBEventBasedExcelExtractor(pkg);
+                       ex.getText();
+
+                       /* Not supported:
+                       ex.setFormulasNotResults(true);
+                       ex.getText();*/
+
+                       ex.setHandleHyperlinksInCells(true);
+                       ex.getText();
+               } catch (IOException | XmlException | OpenXML4JException | 
POIXMLException |
+                 RecordFormatException | IndexOutOfBoundsException | 
IllegalArgumentException |
+                                IllegalStateException | ArithmeticException | 
XSSFBParseException ex) {
+                       // expected
+               } catch (NullPointerException e) {
+                       // can be removed when commons-compress is > 1.28.0 and 
changes from COMPRESS-598 are applied
+                       if 
(!ExceptionUtils.getStackTrace(e).contains("org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.read"))
 {
+                               throw e;
+                       }
+        }
+       }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to