]> source.dussan.org Git - poi.git/commitdiff
Detect when the Current User stream is too short, and give a more helpful exception...
authorNick Burch <nick@apache.org>
Mon, 20 Nov 2006 12:26:51 +0000 (12:26 +0000)
committerNick Burch <nick@apache.org>
Mon, 20 Nov 2006 12:26:51 +0000 (12:26 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@477162 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hslf/record/CurrentUserAtom.java

index 2fa6803e563f639d08d1fc2f46f6d6e910b5011a..d75d7809ea304a56b7c38ac2424e6cca16b75814 100644 (file)
@@ -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);