Kaydet (Commit) aed68b0c authored tarafından Caolán McNamara's avatar Caolán McNamara Kaydeden (comit) David Tardon

detect and reject loop in tif

Change-Id: I77d315fa432a3eb1a65539489a2ba6da8508b283
(cherry picked from commit 6b82437d)
Reviewed-on: https://gerrit.libreoffice.org/17957Reviewed-by: 's avatarDavid Tardon <dtardon@redhat.com>
Tested-by: 's avatarDavid Tardon <dtardon@redhat.com>
üst d8b8bb7b
......@@ -19,6 +19,8 @@
#include "lzwdecom.hxx"
#include <algorithm>
#include <vector>
#define MAX_TABLE_SIZE 4096
......@@ -161,8 +163,18 @@ void LZWDecompressor::AddToTable(sal_uInt16 nPrevCode, sal_uInt16 nCodeFirstData
return;
}
std::vector<sal_uInt16> aSeenIndexes;
while (pTable[nCodeFirstData].nDataCount>1)
{
if (std::find(aSeenIndexes.begin(), aSeenIndexes.end(), nCodeFirstData) != aSeenIndexes.end())
{
SAL_WARN("filter.tiff", "Loop in chain");
bEOIFound = true;
return;
}
aSeenIndexes.push_back(nCodeFirstData);
nCodeFirstData=pTable[nCodeFirstData].nPrevCode;
}
pTable[nTableSize].nPrevCode=nPrevCode;
pTable[nTableSize].nDataCount=pTable[nPrevCode].nDataCount+1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment