Author: centic Date: Sat Dec 30 11:11:42 2023 New Revision: 1914991 URL: http://svn.apache.org/viewvc?rev=1914991&view=rev Log: Bug 66425: Avoid exceptions found via poi-fuzz
Prevent ClassCastException Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=63504 Added: poi/trunk/test-data/spreadsheet/clusterfuzz-testcase-minimized-POIHSSFFuzzer-4977868385681408.xls Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFShapeFactory.java poi/trunk/poi/src/test/java/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java poi/trunk/poi/src/test/java/org/apache/poi/hssf/model/TestDrawingAggregate.java poi/trunk/test-data/spreadsheet/stress.xls Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFShapeFactory.java URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFShapeFactory.java?rev=1914991&r1=1914990&r2=1914991&view=diff ============================================================================== --- poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFShapeFactory.java (original) +++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFShapeFactory.java Sat Dec 30 11:11:42 2023 @@ -57,7 +57,11 @@ public class HSSFShapeFactory { } EscherClientDataRecord clientData = ((EscherContainerRecord) child).getChildById(EscherClientDataRecord.RECORD_ID); if (null != clientData) { - obj = (ObjRecord) agg.getShapeToObjMapping().get(clientData); + Record record = agg.getShapeToObjMapping().get(clientData); + if (!(record instanceof ObjRecord)) { + throw new IllegalArgumentException("Had unexpected type of clientData: " + (record == null ? "<null>" : record.getClass())); + } + obj = (ObjRecord) record; } HSSFShapeGroup group = new HSSFShapeGroup(container, obj); List<EscherContainerRecord> children = container.getChildContainers(); Modified: poi/trunk/poi/src/test/java/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java?rev=1914991&r1=1914990&r2=1914991&view=diff ============================================================================== --- poi/trunk/poi/src/test/java/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java (original) +++ poi/trunk/poi/src/test/java/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java Sat Dec 30 11:11:42 2023 @@ -57,6 +57,7 @@ class TestBiffDrawingToXml extends BaseT excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5285517825277952.xls", IllegalArgumentException.class); excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5436547081830400.xls", IllegalArgumentException.class); excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5889658057523200.xls", IndexOutOfBoundsException.class); + excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-4977868385681408.xls", IllegalArgumentException.class); return excludes; } Modified: poi/trunk/poi/src/test/java/org/apache/poi/hssf/model/TestDrawingAggregate.java URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/hssf/model/TestDrawingAggregate.java?rev=1914991&r1=1914990&r2=1914991&view=diff ============================================================================== --- poi/trunk/poi/src/test/java/org/apache/poi/hssf/model/TestDrawingAggregate.java (original) +++ poi/trunk/poi/src/test/java/org/apache/poi/hssf/model/TestDrawingAggregate.java Sat Dec 30 11:11:42 2023 @@ -138,7 +138,9 @@ class TestDrawingAggregate { File[] files = testData.listFiles((dir, name) -> name.endsWith(".xls")); assertNotNull(files, "Need to find files in test-data path, had path: " + testData); return Stream.of(files). - filter(file -> !file.getName().equals("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5285517825277952.xls")). + filter(file -> + !file.getName().equals("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5285517825277952.xls") && + !file.getName().equals("clusterfuzz-testcase-minimized-POIHSSFFuzzer-4977868385681408.xls")). map(Arguments::of); } Added: poi/trunk/test-data/spreadsheet/clusterfuzz-testcase-minimized-POIHSSFFuzzer-4977868385681408.xls URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/clusterfuzz-testcase-minimized-POIHSSFFuzzer-4977868385681408.xls?rev=1914991&view=auto ============================================================================== Binary files poi/trunk/test-data/spreadsheet/clusterfuzz-testcase-minimized-POIHSSFFuzzer-4977868385681408.xls (added) and poi/trunk/test-data/spreadsheet/clusterfuzz-testcase-minimized-POIHSSFFuzzer-4977868385681408.xls Sat Dec 30 11:11:42 2023 differ Modified: poi/trunk/test-data/spreadsheet/stress.xls URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/stress.xls?rev=1914991&r1=1914990&r2=1914991&view=diff ============================================================================== Binary files - no diff available. --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@poi.apache.org For additional commands, e-mail: commits-h...@poi.apache.org