Added more sanity checking to JPEG2000 layer boundary decoding

git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@2362 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
John Hurliman
2008-11-18 19:13:25 +00:00
parent 5fbcd0c4d6
commit c4bcb8e2bc

View File

@@ -358,7 +358,27 @@ namespace OpenMetaverse.Imaging
layerInfo[i].End = endPacket.end_pos;
}
success = true;
// More sanity checking
if (layerInfo[layerInfo.Length - 1].End <= encoded.Length - 1)
{
success = true;
for (int i = 0; i < layerInfo.Length; i++)
{
if (layerInfo[i].Start >= layerInfo[i].End ||
(i > 0 && layerInfo[i].Start <= layerInfo[i - 1].End))
{
success = false;
Logger.Log("Inconsistent packet data in JPEG2000 stream", Helpers.LogLevel.Warning);
}
}
}
else
{
Logger.Log(String.Format(
"Last packet end in JPEG2000 stream extends beyond the end of the file. filesize={0} layerend={1}",
encoded.Length, layerInfo[layerInfo.Length - 1].End), Helpers.LogLevel.Warning);
}
}
else
{