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 e5dfcaecdc6c3f7c1cd2f6ea6ecf2e37f7da56b4 Author: Dominik Stadler <[email protected]> AuthorDate: Sun Aug 16 10:09:39 2026 +0200 Avoid an NPE during formula parsing https://issues.oss-fuzz.com/issues/529210360 --- .../org/apache/poi/ss/tests/formula/TestFormulaParser.java | 6 ++++++ .../apache/poi/hssf/usermodel/HSSFEvaluationWorkbook.java | 5 ++++- test-data/poi-integration-exceptions.csv | 1 + ...case-minimized-FormulaParserFuzzer-6709334927802368.dat | Bin 0 -> 10 bytes 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/poi-ooxml/src/test/java/org/apache/poi/ss/tests/formula/TestFormulaParser.java b/poi-ooxml/src/test/java/org/apache/poi/ss/tests/formula/TestFormulaParser.java index fe65c24421..d39cc3866c 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/ss/tests/formula/TestFormulaParser.java +++ b/poi-ooxml/src/test/java/org/apache/poi/ss/tests/formula/TestFormulaParser.java @@ -208,4 +208,10 @@ class TestFormulaParser { void testUnicodeSheetName() { checkFormula("'Sheet\u30FB1'!A1:A6"); } + + @Test + void testNPE() { + assertThrows(FormulaParseException.class, + () -> checkFormula("r:[]!d:F��")); + } } diff --git a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFEvaluationWorkbook.java b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFEvaluationWorkbook.java index 08a8c56e82..6b16c74de4 100644 --- a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFEvaluationWorkbook.java +++ b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFEvaluationWorkbook.java @@ -286,7 +286,10 @@ public final class HSSFEvaluationWorkbook implements FormulaRenderingWorkbook, E String lastSheetName = firstSheetName; if (sheetIden instanceof SheetRangeIdentifier sheetRange) { - lastSheetName = sheetRange.getLastSheetIdentifier().getName(); + NameIdentifier lastSheetIdentifier = sheetRange.getLastSheetIdentifier(); + if (lastSheetIdentifier != null) { + lastSheetName = lastSheetIdentifier.getName(); + } } if (workbookName == null) { diff --git a/test-data/poi-integration-exceptions.csv b/test-data/poi-integration-exceptions.csv index 4a9ea16a24..96b8ebd4d1 100644 --- a/test-data/poi-integration-exceptions.csv +++ b/test-data/poi-integration-exceptions.csv @@ -396,3 +396,4 @@ spreadsheet/LIBRE_OFFICE-128382-0.xlsx,handle,XSSF,,org.apache.poi.ss.formula.Fo spreadsheet/LIBRE_OFFICE-116306-0.xlsx,extract,"XSSF,OPC",,org.apache.poi.util.RecordFormatException,Tried to allocate an array spreadsheet/LIBRE_OFFICE-116306-0.xlsx,handle,XSSF,,org.apache.poi.util.RecordFormatException,Tried to allocate an array spreadsheet/clusterfuzz-testcase-minimized-POIFileHandlerFuzzer-5318384433823744.emf,"handle,extract",HEMF,,org.apache.poi.util.RecordFormatException,Invalid value for undefinedSpace2 +spreadsheet/clusterfuzz-testcase-minimized-FormulaParserFuzzer-6709334927802368.dat,handle,HMEF,,java.lang.IllegalArgumentException,TNEF signature not detected in file diff --git a/test-data/spreadsheet/clusterfuzz-testcase-minimized-FormulaParserFuzzer-6709334927802368.dat b/test-data/spreadsheet/clusterfuzz-testcase-minimized-FormulaParserFuzzer-6709334927802368.dat new file mode 100644 index 0000000000..27c21fcd2f Binary files /dev/null and b/test-data/spreadsheet/clusterfuzz-testcase-minimized-FormulaParserFuzzer-6709334927802368.dat differ --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
