Added detection for broken WAD files

Do not try to allocate nonsensical amount of memory and bail out when broken WAD is detected
See http://forum.drdteam.org/viewtopic.php?t=6844
This commit is contained in:
alexey.lysiuk 2016-03-04 11:20:19 +02:00 committed by Christoph Oelckers
parent 93323b64f8
commit 9b23b41021
1 changed files with 7 additions and 0 deletions

View File

@ -39,6 +39,7 @@
#include "v_text.h"
#include "w_wad.h"
#include "gi.h"
#include "i_system.h"
// Console Doom LZSS wrapper.
class FileReaderLZSS : public FileReaderBase
@ -343,6 +344,12 @@ bool FWadFile::Open(bool quiet)
NumLumps = BigLong(header.NumLumps);
InfoTableOfs = BigLong(header.InfoTableOfs);
isBigEndian = true;
// Check again to detect broken wads
if (InfoTableOfs + NumLumps*sizeof(wadlump_t) > (unsigned)wadSize)
{
I_Error("Cannot load broken WAD file %s\n", Filename);
}
}
wadlump_t *fileinfo = new wadlump_t[NumLumps];