while(pos < rawContents.length && textHandled < prsize) {
// First up, fetch the number of characters this applies to
int textLen = LittleEndian.getInt(rawContents,pos);
+ textLen = checkTextLength(textLen, textHandled, size);
textHandled += textLen;
pos += 4;
while(pos < rawContents.length && textHandled < chsize) {
// First up, fetch the number of characters this applies to
int textLen = LittleEndian.getInt(rawContents,pos);
+ textLen = checkTextLength(textLen, textHandled, size);
textHandled += textLen;
pos += 4;
initialised = true;
}
+
+ private int checkTextLength(int readLength, int handledSoFar, int overallSize) {
+ if (readLength + handledSoFar > overallSize + 1) {
+ logger.log(POILogger.WARN, "Style length of " + readLength + " at " + handledSoFar +
+ " larger than stated size of " + overallSize + ", truncating");
+ return overallSize + 1 - handledSoFar;
+ }
+ return readLength;
+ }
/**