Skip to content

Commit

Permalink
TIKA-1152: Process loops infinitely on parsing of a CHM file
Browse files Browse the repository at this point in the history
Patch by Hong-Thai Nguyen

git-svn-id: https://svn.apache.org/repos/asf/tika/trunk@1553621 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
jukka committed Dec 27, 2013
1 parent 8d794b5 commit 3dec312
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ private void assertStateNotNull() throws TikaException {
private void extractContent() throws TikaException {
assertStateNotNull();
if (getChmSection().getData() != null) {
while (getContentLength() < getBlockLength()) {// && tempStopLoop
boolean continueLoop = true;
while (continueLoop && getContentLength() < getBlockLength()) {
if (getState() != null && getState().getBlockRemaining() == 0) {
if (getState().getHadStarted() == LzxState.NOT_STARTED_DECODING) {
getState().setHadStarted(LzxState.STARTED_DECODING);
Expand Down Expand Up @@ -183,6 +184,7 @@ private void extractContent() throws TikaException {
getState().setBlockRemaining(0);
}

int lastLength = getContentLength();
switch (getState().getBlockType()) {
case ChmCommons.ALIGNED_OFFSET:
// if(prevblock.lzxState.length>prevblock.lzxState.remaining)
Expand All @@ -200,6 +202,8 @@ private void extractContent() throws TikaException {
if ((getState().getFramesRead() < 32768)
&& getState().getIntelFileSize() != 0)
intelE8Decoding();

continueLoop = getContentLength() > lastLength;
}
}
}
Expand Down Expand Up @@ -277,7 +281,7 @@ private void createLengthTreeTable() throws TikaException {
ChmConstants.LZX_NUM_SECONDARY_LENGTHS));
}

public void decompressUncompressedBlock(int len, byte[] prevcontent) {
private void decompressUncompressedBlock(int len, byte[] prevcontent) {
if (getContentLength() + getState().getBlockRemaining() <= getBlockLength()) {
for (int i = getContentLength(); i < (getContentLength() + getState()
.getBlockRemaining()); i++)
Expand All @@ -296,7 +300,7 @@ public void decompressUncompressedBlock(int len, byte[] prevcontent) {
}
}

public void decompressAlignedBlock(int len, byte[] prevcontent) throws TikaException {
private void decompressAlignedBlock(int len, byte[] prevcontent) throws TikaException {

if ((getChmSection() == null) || (getState() == null)
|| (getState().getMainTreeTable() == null))
Expand Down

0 comments on commit 3dec312

Please sign in to comment.