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
This commit is contained in:
parent
23303f691f
commit
fd3bbdbd1c
@ -23,6 +23,7 @@ import java.io.*;
|
|||||||
import org.apache.poi.poifs.filesystem.*;
|
import org.apache.poi.poifs.filesystem.*;
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
import org.apache.poi.util.StringUtil;
|
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");
|
(DocumentEntry)fs.getRoot().getEntry("Current User");
|
||||||
_contents = new byte[docProps.getSize()];
|
_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
|
// Grab the contents
|
||||||
InputStream in = fs.createDocumentInputStream("Current User");
|
InputStream in = fs.createDocumentInputStream("Current User");
|
||||||
in.read(_contents);
|
in.read(_contents);
|
||||||
|
Loading…
Reference in New Issue
Block a user