Bug 66425: Avoid exceptions found via poi-fuzz

Prevent ClassCastException

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

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1914991 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2023-12-30 11:11:42 +00:00
parent 28811d26df
commit 8507fdf371
5 changed files with 9 additions and 2 deletions

View File

@ -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();

View File

@ -57,6 +57,7 @@ class TestBiffDrawingToXml extends BaseTestIteratingXLS {
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;
}

View File

@ -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);
}

Binary file not shown.