Browse Source

Bug 66425: Avoid exceptions found via poi-fuzz

Capture and report integer overflow as normal
parsing/format exceptions

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=63628

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1914401 13f79535-47bb-0310-9956-ffa450edef68
pull/562/head
Dominik Stadler 5 months ago
parent
commit
9fda604fb8

+ 7
- 2
poi-examples/src/main/java/org/apache/poi/examples/xssf/eventusermodel/XLSX2CSV.java View File

styles, null, strings, sheetHandler, formatter, false); styles, null, strings, sheetHandler, formatter, false);
sheetParser.setContentHandler(handler); sheetParser.setContentHandler(handler);
sheetParser.parse(sheetSource); sheetParser.parse(sheetSource);
} catch(ParserConfigurationException e) {
} catch (ParserConfigurationException e) {
throw new RuntimeException("SAX parser appears to be broken - " + e.getMessage()); throw new RuntimeException("SAX parser appears to be broken - " + e.getMessage());
} }
} }
String sheetName = iter.getSheetName(); String sheetName = iter.getSheetName();
this.output.println(); this.output.println();
this.output.println(sheetName + " [index=" + index + "]:"); this.output.println(sheetName + " [index=" + index + "]:");
processSheet(styles, strings, new SheetToCSV(), stream);

try {
processSheet(styles, strings, new SheetToCSV(), stream);
} catch (NumberFormatException e) {
throw new IOException("Failed to parse sheet " + sheetName, e);
}
} }
++index; ++index;
} }

+ 1
- 1
poi-ooxml/src/main/java/org/apache/poi/xssf/extractor/XSSFEventBasedExcelExtractor.java View File

} }


return text.toString(); return text.toString();
} catch (IOException | OpenXML4JException | SAXException e) {
} catch (IOException | OpenXML4JException | SAXException | NumberFormatException e) {
LOGGER.atWarn().withThrowable(e).log("Failed to load text"); LOGGER.atWarn().withThrowable(e).log("Failed to load text");
return ""; return "";
} }

+ 1
- 1
poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java View File

protected void onDocumentRead() { protected void onDocumentRead() {
try (InputStream stream = getPackagePart().getInputStream()) { try (InputStream stream = getPackagePart().getInputStream()) {
read(stream); read(stream);
} catch (IOException e){
} catch (IOException | ArithmeticException e){
throw new POIXMLException(e); throw new POIXMLException(e);
} }
} }

BIN
test-data/spreadsheet/clusterfuzz-testcase-minimized-POIXSSFFuzzer-5937385319563264.xlsx View File


BIN
test-data/spreadsheet/stress.xls View File


Loading…
Cancel
Save