Browse 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=61276

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1911536 13f79535-47bb-0310-9956-ffa450edef68
tags/REL_5_2_4
Dominik Stadler 9 months ago
parent
commit
e706f37170

+ 3
- 0
poi/src/main/java/org/apache/poi/hssf/record/TextObjectRecord.java View File

throw new RecordFormatException("Read " + ptgs.length throw new RecordFormatException("Read " + ptgs.length
+ " tokens but expected exactly 1"); + " tokens but expected exactly 1");
} }
if (!(ptgs[0] instanceof OperandPtg)) {
throw new IllegalArgumentException("Had unexpected type of ptg at index 0: " + ptgs[0].getClass());
}
_linkRefPtg = (OperandPtg) ptgs[0]; _linkRefPtg = (OperandPtg) ptgs[0];
_unknownPostFormulaByte = in.remaining() > 0 ? in.readByte() : null; _unknownPostFormulaByte = in.remaining() > 0 ? in.readByte() : null;
} else { } else {

+ 2
- 0
poi/src/test/java/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java View File

excludes.put("61300.xls", RecordFormatException.class); excludes.put("61300.xls", RecordFormatException.class);
// BIFF 5 // BIFF 5
excludes.put("64130.xls", OldExcelFormatException.class); excludes.put("64130.xls", OldExcelFormatException.class);
// fuzzed binaries
excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-6322470200934400.xls", RuntimeException.class);
return excludes; return excludes;
} }



BIN
test-data/spreadsheet/clusterfuzz-testcase-minimized-POIHSSFFuzzer-6322470200934400.xls View File


BIN
test-data/spreadsheet/stress.xls View File


Loading…
Cancel
Save