aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/poi/hpsf
diff options
context:
space:
mode:
authorYegor Kozlov <yegor@apache.org>2012-02-15 07:49:25 +0000
committerYegor Kozlov <yegor@apache.org>2012-02-15 07:49:25 +0000
commitb10ba1a85bfcb606423b809515693258a2143075 (patch)
treea079c17a504e81108e6dae06b9f6e02cbf5c8905 /src/java/org/apache/poi/hpsf
parent9e1165c24a8546d9472ef0cd1f1a9cf959013274 (diff)
downloadpoi-b10ba1a85bfcb606423b809515693258a2143075.tar.gz
poi-b10ba1a85bfcb606423b809515693258a2143075.zip
Bugzilla 52385,52337,52338: avoid trancated array and vector data when reading OLE properties
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1244388 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi/hpsf')
-rw-r--r--src/java/org/apache/poi/hpsf/Property.java20
-rw-r--r--src/java/org/apache/poi/hpsf/TypedPropertyValue.java2
-rw-r--r--src/java/org/apache/poi/hpsf/Vector.java4
3 files changed, 22 insertions, 4 deletions
diff --git a/src/java/org/apache/poi/hpsf/Property.java b/src/java/org/apache/poi/hpsf/Property.java
index 90cc014082..026ff32260 100644
--- a/src/java/org/apache/poi/hpsf/Property.java
+++ b/src/java/org/apache/poi/hpsf/Property.java
@@ -414,9 +414,9 @@ public class Property
b.append(getType());
final Object value = getValue();
b.append(", value: ");
- b.append(value.toString());
if (value instanceof String)
{
+ b.append(value.toString());
final String s = (String) value;
final int l = s.length();
final byte[] bytes = new byte[l * 2];
@@ -428,11 +428,25 @@ public class Property
bytes[i * 2] = high;
bytes[i * 2 + 1] = low;
}
- final String hex = HexDump.dump(bytes, 0L, 0);
b.append(" [");
- b.append(hex);
+ if(bytes.length > 0) {
+ final String hex = HexDump.dump(bytes, 0L, 0);
+ b.append(hex);
+ }
b.append("]");
}
+ else if (value instanceof byte[])
+ {
+ byte[] bytes = (byte[])value;
+ if(bytes.length > 0) {
+ String hex = HexDump.dump(bytes, 0L, 0);
+ b.append(hex);
+ }
+ }
+ else
+ {
+ b.append(value.toString());
+ }
b.append(']');
return b.toString();
}
diff --git a/src/java/org/apache/poi/hpsf/TypedPropertyValue.java b/src/java/org/apache/poi/hpsf/TypedPropertyValue.java
index 982139ba8a..43ac27aeba 100644
--- a/src/java/org/apache/poi/hpsf/TypedPropertyValue.java
+++ b/src/java/org/apache/poi/hpsf/TypedPropertyValue.java
@@ -68,7 +68,7 @@ class TypedPropertyValue
+ offset + " MUST be 0, but it's value is " + padding );
}
- offset += readValuePadded( data, offset );
+ offset += readValue( data, offset );
return offset - startOffset;
}
diff --git a/src/java/org/apache/poi/hpsf/Vector.java b/src/java/org/apache/poi/hpsf/Vector.java
index 9cfa14310b..145a660cdb 100644
--- a/src/java/org/apache/poi/hpsf/Vector.java
+++ b/src/java/org/apache/poi/hpsf/Vector.java
@@ -16,6 +16,7 @@
==================================================================== */
package org.apache.poi.hpsf;
+import org.apache.poi.util.HexDump;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
@@ -78,4 +79,7 @@ class Vector
return offset - startOffset;
}
+ TypedPropertyValue[] getValues(){
+ return _values;
+ }
}