mirror of https://github.com/apache/poi.git
Bug 66425: Avoid exceptions found via poi-fuzz
Avoid a ClassCastException and trigger some more code in integration-testing. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=63358 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1914404 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c7329fbd38
commit
15dd62d659
|
@ -109,13 +109,38 @@ public abstract class AbstractFileHandler implements FileHandler {
|
|||
assertEquals(modified, file.lastModified(), "File should not be modified by extractor");
|
||||
|
||||
if (extractor instanceof POIOLE2TextExtractor) {
|
||||
try (HPSFPropertiesExtractor hpsfExtractor = new HPSFPropertiesExtractor((POIOLE2TextExtractor) extractor)) {
|
||||
POIOLE2TextExtractor ole2Extractor = (POIOLE2TextExtractor) extractor;
|
||||
ole2Extractor.getRoot();
|
||||
if (!(ole2Extractor instanceof EventBasedExcelExtractor)) {
|
||||
ole2Extractor.getSummaryInformation();
|
||||
ole2Extractor.getDocSummaryInformation();
|
||||
}
|
||||
|
||||
try (HPSFPropertiesExtractor hpsfExtractor = new HPSFPropertiesExtractor(ole2Extractor)) {
|
||||
assertNotNull(hpsfExtractor.getDocumentSummaryInformationText());
|
||||
assertNotNull(hpsfExtractor.getSummaryInformationText());
|
||||
String text = hpsfExtractor.getText();
|
||||
//System.out.println(text);
|
||||
assertNotNull(text);
|
||||
}
|
||||
|
||||
if (ole2Extractor.getRoot() != null && !Boolean.getBoolean("scratchpad.ignore")) {
|
||||
POITextExtractor[] embedded = ExtractorFactory.getEmbeddedDocsTextExtractors(ole2Extractor);
|
||||
try {
|
||||
for (POITextExtractor poiTextExtractor : embedded) {
|
||||
poiTextExtractor.getText();
|
||||
poiTextExtractor.getDocument();
|
||||
poiTextExtractor.getFilesystem();
|
||||
POITextExtractor metaData = poiTextExtractor.getMetadataTextExtractor();
|
||||
metaData.getFilesystem();
|
||||
metaData.getText();
|
||||
}
|
||||
} finally {
|
||||
for (POITextExtractor embeddedExtractor : embedded) {
|
||||
embeddedExtractor.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// test again with including formulas and cell-comments as this caused some bugs
|
||||
|
@ -166,6 +191,8 @@ public abstract class AbstractFileHandler implements FileHandler {
|
|||
assertNotNull(streamExtractor);
|
||||
|
||||
assertNotNull(streamExtractor.getText());
|
||||
|
||||
assertNotNull(streamExtractor.getMetadataTextExtractor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -373,8 +373,10 @@ public final class ExtractorFactory {
|
|||
|
||||
ArrayList<POITextExtractor> textExtractors = new ArrayList<>();
|
||||
for (Entry dir : dirs) {
|
||||
if (dir instanceof DirectoryNode) {
|
||||
textExtractors.add(createExtractor((DirectoryNode) dir));
|
||||
}
|
||||
}
|
||||
for (InputStream stream : nonPOIFS) {
|
||||
try {
|
||||
textExtractors.add(createExtractor(stream));
|
||||
|
|
|
@ -44,6 +44,7 @@ class TestBiffViewer extends BaseTestIteratingXLS {
|
|||
excludes.put("protected_66115.xls", RecordFormatException.class);
|
||||
excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5786329142919168.xls", IllegalStateException.class);
|
||||
excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5889658057523200.xls", IndexOutOfBoundsException.class);
|
||||
excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5175219985448960.xls", IndexOutOfBoundsException.class);
|
||||
|
||||
return excludes;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ class TestRecordLister extends BaseTestIteratingXLS {
|
|||
Map<String, Class<? extends Throwable>> excludes = super.getExcludes();
|
||||
excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5786329142919168.xls", RecordFormatException.class);
|
||||
excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5889658057523200.xls", IndexOutOfBoundsException.class);
|
||||
excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5175219985448960.xls", RecordFormatException.class);
|
||||
return excludes;
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue