Selaa lähdekoodia

Bug 66425: Avoid exceptions found via poi-fuzz

We try to avoid throwing NullPointerException, ClassCastExceptions and StackOverflowException, but it was possible
to trigger them

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=62548 and https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=62564

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912464 13f79535-47bb-0310-9956-ffa450edef68
tags/REL_5_2_4
Dominik Stadler 8 kuukautta sitten
vanhempi
commit
c79fb75cbc

+ 6
- 2
poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFDiagram.java Näytä tiedosto

CTGroupShapeProperties groupShapePropsCt = groupShapeCt.addNewGrpSpPr(); CTGroupShapeProperties groupShapePropsCt = groupShapeCt.addNewGrpSpPr();


CTGroupShapeNonVisual groupShapeNonVisualCt = groupShapeCt.addNewNvGrpSpPr(); CTGroupShapeNonVisual groupShapeNonVisualCt = groupShapeCt.addNewNvGrpSpPr();
groupShapeNonVisualCt.setCNvPr(msGroupShapeCt.getNvGrpSpPr().getCNvPr());
groupShapeNonVisualCt.setCNvGrpSpPr(msGroupShapeCt.getNvGrpSpPr().getCNvGrpSpPr());
final com.microsoft.schemas.office.drawing.x2008.diagram.CTGroupShapeNonVisual nvGrpSpPr =
msGroupShapeCt.getNvGrpSpPr();
if (nvGrpSpPr != null) {
groupShapeNonVisualCt.setCNvPr(nvGrpSpPr.getCNvPr());
groupShapeNonVisualCt.setCNvGrpSpPr(nvGrpSpPr.getCNvGrpSpPr());
}
groupShapeNonVisualCt.setNvPr(CTApplicationNonVisualDrawingProps.Factory.newInstance()); groupShapeNonVisualCt.setNvPr(CTApplicationNonVisualDrawingProps.Factory.newInstance());


for (CTShape msShapeCt : msGroupShapeCt.getSpList()) { for (CTShape msShapeCt : msGroupShapeCt.getSpList()) {

+ 1
- 0
poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/BaseTestPPTIterating.java Näytä tiedosto

EXCLUDED.put("clusterfuzz-testcase-minimized-POIFuzzer-5681320547975168.ppt", FileNotFoundException.class); EXCLUDED.put("clusterfuzz-testcase-minimized-POIFuzzer-5681320547975168.ppt", FileNotFoundException.class);
EXCLUDED.put("clusterfuzz-testcase-minimized-POIHSLFFuzzer-5962760801091584.ppt", RuntimeException.class); EXCLUDED.put("clusterfuzz-testcase-minimized-POIHSLFFuzzer-5962760801091584.ppt", RuntimeException.class);
EXCLUDED.put("clusterfuzz-testcase-minimized-POIHSLFFuzzer-5231088823566336.ppt", FileNotFoundException.class); EXCLUDED.put("clusterfuzz-testcase-minimized-POIHSLFFuzzer-5231088823566336.ppt", FileNotFoundException.class);
EXCLUDED.put("clusterfuzz-testcase-minimized-POIFuzzer-6411649193738240.ppt", FileNotFoundException.class);
} }


public static Stream<Arguments> files() { public static Stream<Arguments> files() {

+ 2
- 1
poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/TestPPTXMLDump.java Näytä tiedosto

// work around two files which works here but not in other tests // work around two files which works here but not in other tests
if (pFile.getName().equals("clusterfuzz-testcase-minimized-POIFuzzer-5429732352851968.ppt") || if (pFile.getName().equals("clusterfuzz-testcase-minimized-POIFuzzer-5429732352851968.ppt") ||
pFile.getName().equals("clusterfuzz-testcase-minimized-POIFuzzer-5681320547975168.ppt") || pFile.getName().equals("clusterfuzz-testcase-minimized-POIFuzzer-5681320547975168.ppt") ||
pFile.getName().equals("clusterfuzz-testcase-minimized-POIHSLFFuzzer-5231088823566336.ppt")) {
pFile.getName().equals("clusterfuzz-testcase-minimized-POIHSLFFuzzer-5231088823566336.ppt") ||
pFile.getName().equals("clusterfuzz-testcase-minimized-POIFuzzer-6411649193738240.ppt")) {
throw new FileNotFoundException(); throw new FileNotFoundException();
} }
} }

+ 1
- 1
poi/src/main/java/org/apache/poi/poifs/crypt/agile/KeyData.java Näytä tiedosto

blockSize = getIntAttr(keyData, "blockSize"); blockSize = getIntAttr(keyData, "blockSize");
keyBits = getIntAttr(keyData, "keyBits"); keyBits = getIntAttr(keyData, "keyBits");
hashSize = getIntAttr(keyData, "hashSize"); hashSize = getIntAttr(keyData, "hashSize");
cipherAlgorithm = CipherAlgorithm.fromXmlId(keyData.getAttribute("cipherAlgorithm"), keyBits);
cipherAlgorithm = CipherAlgorithm.fromXmlId(keyData.getAttribute("cipherAlgorithm"), keyBits == null ? -1 : keyBits);
cipherChaining = ChainingMode.fromXmlId(keyData.getAttribute("cipherChaining")); cipherChaining = ChainingMode.fromXmlId(keyData.getAttribute("cipherChaining"));
hashAlgorithm = HashAlgorithm.fromEcmaId(keyData.getAttribute("hashAlgorithm")); hashAlgorithm = HashAlgorithm.fromEcmaId(keyData.getAttribute("hashAlgorithm"));
if (cipherAlgorithm == null || cipherChaining == null || hashAlgorithm == null) { if (cipherAlgorithm == null || cipherChaining == null || hashAlgorithm == null) {

BIN
test-data/slideshow/clusterfuzz-testcase-minimized-POIFuzzer-6411649193738240.ppt Näytä tiedosto


BIN
test-data/slideshow/clusterfuzz-testcase-minimized-POIXSLFFuzzer-5471515212382208.pptx Näytä tiedosto


BIN
test-data/spreadsheet/stress.xls Näytä tiedosto


Loading…
Peruuta
Tallenna