Parcourir la source

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=61578

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1911860 13f79535-47bb-0310-9956-ffa450edef68
tags/REL_5_2_4
Dominik Stadler il y a 9 mois
Parent
révision
fd29772be6

+ 5
- 1
poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java Voir le fichier

return; return;
} }


DocumentEntry entry = (DocumentEntry) getDirectory().getEntry("Pictures");
final Entry en = getDirectory().getEntry("Pictures");
if (!(en instanceof DocumentEntry)) {
throw new IllegalArgumentException("Had unexpected type of entry for name: Pictures: " + en.getClass());
}
DocumentEntry entry = (DocumentEntry) en;
EscherContainerRecord blipStore = getBlipStore(); EscherContainerRecord blipStore = getBlipStore();
byte[] pictstream; byte[] pictstream;
try (DocumentInputStream is = getDirectory().createDocumentInputStream(entry)) { try (DocumentInputStream is = getDirectory().createDocumentInputStream(entry)) {

+ 3
- 1
poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/TestPPTXMLDump.java Voir le fichier

import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;


import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
static final Set<String> LOCAL_EXCLUDED = new HashSet<>(); static final Set<String> LOCAL_EXCLUDED = new HashSet<>();
static { static {
LOCAL_EXCLUDED.add("clusterfuzz-testcase-minimized-POIHSLFFuzzer-5306877435838464.ppt"); LOCAL_EXCLUDED.add("clusterfuzz-testcase-minimized-POIHSLFFuzzer-5306877435838464.ppt");
LOCAL_EXCLUDED.add("clusterfuzz-testcase-minimized-POIHSLFFuzzer-6032591399288832.ppt");
} }


@Test @Test
void runOneFile(File pFile) throws Exception { void runOneFile(File pFile) throws Exception {
try { try {
PPTXMLDump.main(new String[]{pFile.getAbsolutePath()}); PPTXMLDump.main(new String[]{pFile.getAbsolutePath()});
} catch (IndexOutOfBoundsException e) {
} catch (IndexOutOfBoundsException | IOException e) {
if (!LOCAL_EXCLUDED.contains(pFile.getName())) { if (!LOCAL_EXCLUDED.contains(pFile.getName())) {
throw e; throw e;
} }

BIN
test-data/slideshow/clusterfuzz-testcase-minimized-POIHSLFFuzzer-6032591399288832.ppt Voir le fichier


BIN
test-data/spreadsheet/stress.xls Voir le fichier


Chargement…
Annuler
Enregistrer