aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2020-04-24 21:31:49 +0000
committerAndreas Beeker <kiwiwings@apache.org>2020-04-24 21:31:49 +0000
commit6ae31c8a67aeca159f1f0f0eeb5a62a690b1ebba (patch)
tree1d60b6a3c0584a7d42eb47c30c27a3fb637d7f00
parentc7c5fc23bed47c613afa0bc980d1b19102d9de09 (diff)
downloadpoi-6ae31c8a67aeca159f1f0f0eeb5a62a690b1ebba.tar.gz
poi-6ae31c8a67aeca159f1f0f0eeb5a62a690b1ebba.zip
Replace assertion with exception
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1876951 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfFont.java8
-rw-r--r--src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfRecordIterator.java4
2 files changed, 7 insertions, 5 deletions
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfFont.java b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfFont.java
index b95f83c3cf..c7f189f1d5 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfFont.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfFont.java
@@ -461,17 +461,17 @@ public class HemfFont extends HwmfFont {
// A 32-bit unsigned integer that specifies the number of elements in the
// Values array. It MUST be in the range 0 to 16, inclusive.
int numAxes = leis.readInt();
- assert (0 <= numAxes && numAxes <= 16);
+ size += 2*LittleEndianConsts.INT_SIZE;
// An optional array of 32-bit signed integers that specify the values of the font axes of a
// multiple master, OpenType font. The maximum number of values in the array is 16.
- if (numAxes > 0) {
+ if (0 <= numAxes && numAxes <= 16) {
logEx.designVector = new int[numAxes];
for (int i=0; i<numAxes; i++) {
logEx.designVector[i] = leis.readInt();
}
+ size += numAxes*LittleEndianConsts.INT_SIZE;
}
- size += (2+numAxes)*LittleEndianConsts.INT_SIZE;
}
return size;
@@ -532,9 +532,9 @@ public class HemfFont extends HwmfFont {
b1 = buf[readBytes++];
b2 = buf[readBytes++];
} while ((b1 != 0 || b2 != 0) && b1 != -1 && b2 != -1 && readBytes <= limit*2);
-
sb.append(new String(buf, 0, readBytes-2, StandardCharsets.UTF_16LE));
return limit*2;
}
}
+
diff --git a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfRecordIterator.java b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfRecordIterator.java
index bbe930f4ac..afdcaa533f 100644
--- a/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfRecordIterator.java
+++ b/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfRecordIterator.java
@@ -78,7 +78,9 @@ public class HemfRecordIterator implements Iterator<HemfRecord> {
try {
long remBytes = recordSize - HEADER_SIZE;
long readBytes = record.init(stream, remBytes, recordId);
- assert (readBytes <= remBytes);
+ if (readBytes > remBytes) {
+ throw new RecordFormatException("Record limit exceeded - readBytes: "+readBytes+" / remBytes: "+remBytes);
+ }
stream.skipFully((int) (remBytes - readBytes));
} catch (RecordFormatException e) {
throw e;