Consistency check added when reading property set stream. An IllegalPropertyDataException is thrown if the property set stream is larger than it claims to be.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@550021 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Rainer Klute 2007-06-23 07:44:47 +00:00
parent d04f8956c5
commit 05347bb63d

View File

@ -244,6 +244,16 @@ public class Section
{
ple = (PropertyListEntry) propertyList.get(propertyCount - 1);
ple.length = size - ple.offset;
if (ple.length <= 0)
{
final StringBuffer b = new StringBuffer();
b.append("The property set claims to have a size of ");
b.append(size);
b.append(" bytes. However, it exceeds ");
b.append(ple.offset);
b.append(" bytes.");
throw new IllegalPropertySetDataException(b.toString());
}
}
/* Look for the codepage. */
@ -323,6 +333,20 @@ public class Section
else
return 1;
}
public String toString()
{
final StringBuffer b = new StringBuffer();
b.append(getClass().getName());
b.append("[id=");
b.append(id);
b.append(", offset=");
b.append(offset);
b.append(", length=");
b.append(length);
b.append(']');
return b.toString();
}
}