don't load corrupt wav files
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 19 Nov 2010 15:14:53 +0000 (15:14 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 19 Nov 2010 15:14:53 +0000 (15:14 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10616 d7cf8633-e32d-0410-b094-e92efae38249

snd_wav.c

index 7eb118d..b55c366 100644 (file)
--- a/snd_wav.c
+++ b/snd_wav.c
@@ -84,6 +84,12 @@ static void FindNextChunk(const char *name)
                        data_p = NULL;
                        return;
                }
+               if (data_p + iff_chunk_len > iff_end)
+               {
+                       // truncated chunk!
+                       data_p = NULL;
+                       return;
+               }
                data_p -= 8;
                last_chunk = data_p + 8 + ( (iff_chunk_len + 1) & ~1 );
                if (!strncmp((const char *)data_p, name, 4))