Don't crash on invalid input in the Microsoft Wave reader. /bigfoot

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2949 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Molgrum 2008-05-01 11:59:22 +00:00
parent 5852614cf5
commit 9bda9e9fc1

View file

@ -933,17 +933,22 @@ int GetLittleLong(void)
void FindNextChunk(char *name)
{
unsigned int dataleft;
while (1)
{
data_p=last_chunk;
data_p += 4;
if (data_p >= iff_end)
dataleft = iff_end - last_chunk;
if (dataleft < 8)
{ // didn't find the chunk
data_p = NULL;
return;
}
data_p=last_chunk;
data_p += 4;
dataleft-= 8;
iff_chunk_len = GetLittleLong();
if (iff_chunk_len < 0)
if (iff_chunk_len < 0 || iff_chunk_len > dataleft)
{
data_p = NULL;
return;