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