From 70f29ad79cd4fd798867fbba04c55744c4c0368d Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Mon, 20 Nov 2006 12:26:51 +0000 Subject: [PATCH] Detect when the Current User stream is too short, and give a more helpful exception in that case git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@477162 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/org/apache/poi/hslf/record/CurrentUserAtom.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/CurrentUserAtom.java b/src/scratchpad/src/org/apache/poi/hslf/record/CurrentUserAtom.java index 2fa6803e56..d75d7809ea 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/record/CurrentUserAtom.java +++ b/src/scratchpad/src/org/apache/poi/hslf/record/CurrentUserAtom.java @@ -23,6 +23,7 @@ import java.io.*; import org.apache.poi.poifs.filesystem.*; import org.apache.poi.util.LittleEndian; import org.apache.poi.util.StringUtil; +import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException; /** @@ -96,6 +97,12 @@ public class CurrentUserAtom (DocumentEntry)fs.getRoot().getEntry("Current User"); _contents = new byte[docProps.getSize()]; + // Check it's big enough - if it's not at least 28 bytes long, then + // the record is corrupt + if(_contents.length < 28) { + throw new CorruptPowerPointFileException("The Current User stream must be at least 28 bytes long, but was only " + _contents.length); + } + // Grab the contents InputStream in = fs.createDocumentInputStream("Current User"); in.read(_contents); -- 2.39.5