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=61317 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1911565 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e25c467209
commit
fdeae16b0c
|
@ -54,7 +54,6 @@ import org.apache.poi.util.IOUtils;
|
|||
import org.apache.poi.util.Internal;
|
||||
import org.apache.poi.util.LittleEndianByteArrayInputStream;
|
||||
|
||||
|
||||
/**
|
||||
* This class holds much of the core of a Word document, but
|
||||
* without some of the table structure information.
|
||||
|
@ -187,7 +186,11 @@ public abstract class HWPFDocumentCore extends POIDocument {
|
|||
|
||||
DirectoryEntry objectPoolEntry = null;
|
||||
if (directory.hasEntry(STREAM_OBJECT_POOL)) {
|
||||
objectPoolEntry = (DirectoryEntry) directory.getEntry(STREAM_OBJECT_POOL);
|
||||
final Entry entry = directory.getEntry(STREAM_OBJECT_POOL);
|
||||
if (!(entry instanceof DirectoryEntry)) {
|
||||
throw new IllegalArgumentException("Had unexpected type of entry for name: " + STREAM_OBJECT_POOL + ": " + entry.getClass());
|
||||
}
|
||||
objectPoolEntry = (DirectoryEntry) entry;
|
||||
}
|
||||
_objectPool = new ObjectPoolImpl(objectPoolEntry);
|
||||
}
|
||||
|
|
|
@ -59,7 +59,8 @@ public class TestWordToConverterSuite
|
|||
"Fuzzed.doc",
|
||||
"clusterfuzz-testcase-minimized-POIHWPFFuzzer-5418937293340672.doc",
|
||||
"TestHPSFWritingFunctionality.doc",
|
||||
"clusterfuzz-testcase-minimized-POIHWPFFuzzer-4947285593948160.doc"
|
||||
"clusterfuzz-testcase-minimized-POIHWPFFuzzer-4947285593948160.doc",
|
||||
"clusterfuzz-testcase-minimized-POIHWPFFuzzer-5440721166139392.doc"
|
||||
);
|
||||
|
||||
public static Stream<Arguments> files() {
|
||||
|
|
|
@ -51,7 +51,8 @@ public class TestWordToTextConverter {
|
|||
// Corrupt files
|
||||
"clusterfuzz-testcase-minimized-POIHWPFFuzzer-5418937293340672.doc",
|
||||
"TestHPSFWritingFunctionality.doc",
|
||||
"clusterfuzz-testcase-minimized-POIHWPFFuzzer-4947285593948160.doc"
|
||||
"clusterfuzz-testcase-minimized-POIHWPFFuzzer-4947285593948160.doc",
|
||||
"clusterfuzz-testcase-minimized-POIHWPFFuzzer-5440721166139392.doc"
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue