mirror of https://github.com/apache/poi.git
Bug 66425: Avoid a ClassCastException found via oss-fuzz
We try to avoid throwing ClassCastException, but it was possible to trigger one here with a specially crafted input-file Should fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=61330 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1911586 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
316738c9d0
commit
80264d5648
|
@ -181,6 +181,8 @@ public class AttachmentChunks implements ChunkGroup {
|
|||
// - ATTACH_LONG_PATHNAME
|
||||
// - ATTACH_SIZE
|
||||
final int chunkId = chunk.getChunkId();
|
||||
|
||||
try {
|
||||
if (chunkId == ATTACH_DATA.id) {
|
||||
if (chunk instanceof ByteChunk) {
|
||||
attachData = (ByteChunk) chunk;
|
||||
|
@ -207,6 +209,10 @@ public class AttachmentChunks implements ChunkGroup {
|
|||
|
||||
// And add to the main list
|
||||
allChunks.add(chunk);
|
||||
} catch (ClassCastException e) {
|
||||
throw new IllegalArgumentException("ChunkId and type of chunk did not match, had id " +
|
||||
chunkId + " and type of chunk: " + chunk.getClass(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue