diff options
author | Dominik Stadler <centic@apache.org> | 2023-08-07 14:32:11 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2023-08-07 14:32:11 +0000 |
commit | 2c5264277a879b4adba6593b79053fbb8ae4df29 (patch) | |
tree | 4006a111abd9744d19484af801286c879c25457f | |
parent | f6b1435db196b4a2d7079191a15a4018915f70a5 (diff) | |
download | poi-2c5264277a879b4adba6593b79053fbb8ae4df29.tar.gz poi-2c5264277a879b4adba6593b79053fbb8ae4df29.zip |
Bug 66425: Avoid an AssertionError found via oss-fuzz
We try to avoid throwing AssertionError to be triggered by input data, 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=61251
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1911514 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | poi-integration/src/test/java/org/apache/poi/stress/HSLFFileHandler.java | 2 | ||||
-rw-r--r-- | poi-scratchpad/src/main/java/org/apache/poi/hslf/record/EscherPlaceholder.java | 9 | ||||
-rw-r--r-- | poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFShape.java | 4 | ||||
-rw-r--r-- | test-data/slideshow/clusterfuzz-testcase-minimized-POIHSLFFuzzer-4630915954114560.ppt | bin | 0 -> 12800 bytes | |||
-rw-r--r-- | test-data/spreadsheet/stress.xls | bin | 59392 -> 59904 bytes |
5 files changed, 14 insertions, 1 deletions
diff --git a/poi-integration/src/test/java/org/apache/poi/stress/HSLFFileHandler.java b/poi-integration/src/test/java/org/apache/poi/stress/HSLFFileHandler.java index d496d0b85a..f25da02fa8 100644 --- a/poi-integration/src/test/java/org/apache/poi/stress/HSLFFileHandler.java +++ b/poi-integration/src/test/java/org/apache/poi/stress/HSLFFileHandler.java @@ -84,6 +84,8 @@ public class HSLFFileHandler extends SlideShowHandler { } handleExtracting(file); + + handleAdditional(file); } public static void main(String[] args) throws Exception { diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/EscherPlaceholder.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/EscherPlaceholder.java index 28dff25ce9..f474f2171c 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/EscherPlaceholder.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/EscherPlaceholder.java @@ -20,6 +20,8 @@ package org.apache.poi.hslf.record; import java.util.Map; import java.util.function.Supplier; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.poi.ddf.EscherRecord; import org.apache.poi.ddf.EscherRecordFactory; import org.apache.poi.ddf.EscherSerializationListener; @@ -32,6 +34,8 @@ import org.apache.poi.util.LittleEndian; * the slide layout as specified in the SlideAtom record. */ public class EscherPlaceholder extends EscherRecord { + private static final Logger LOG = LogManager.getLogger(EscherPlaceholder.class); + public static final short RECORD_ID = RecordTypes.OEPlaceholderAtom.typeID; public static final String RECORD_DESCRIPTION = "msofbtClientTextboxPlaceholder"; @@ -59,7 +63,10 @@ public class EscherPlaceholder extends EscherRecord { size = data[offset+13]; unused = LittleEndian.getShort(data, offset+14); - assert(bytesRemaining + 8 == 16); + if (bytesRemaining + 8 != 16) { + LOG.warn("Invalid header-data received, should have 8 bytes left, but had: " + bytesRemaining); + } + return bytesRemaining + 8; } diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFShape.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFShape.java index 8dd66e94fe..007259230f 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFShape.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFShape.java @@ -247,6 +247,10 @@ public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> { } public <T extends EscherRecord> T getEscherChild(int recordId){ + if (_escherContainer == null) { + throw new IllegalStateException("Did not have a container for fetching children"); + } + return _escherContainer.getChildById((short)recordId); } diff --git a/test-data/slideshow/clusterfuzz-testcase-minimized-POIHSLFFuzzer-4630915954114560.ppt b/test-data/slideshow/clusterfuzz-testcase-minimized-POIHSLFFuzzer-4630915954114560.ppt Binary files differnew file mode 100644 index 0000000000..c70d8259a8 --- /dev/null +++ b/test-data/slideshow/clusterfuzz-testcase-minimized-POIHSLFFuzzer-4630915954114560.ppt diff --git a/test-data/spreadsheet/stress.xls b/test-data/spreadsheet/stress.xls Binary files differindex 97591849fd..301d3e61fc 100644 --- a/test-data/spreadsheet/stress.xls +++ b/test-data/spreadsheet/stress.xls |