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-ffa450edef68pull/562/head
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; | ||||
} | } |
} | } | ||||
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 ""; | ||||
} | } |
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); | ||||
} | } | ||||
} | } |