Added lump size validation to the WAD loader

(cherry picked from commit cbe4c9c5c1)
This commit is contained in:
Christoph Oelckers 2018-06-27 08:51:45 +02:00 committed by drfrag666
parent 021f5cf656
commit bf632cc31a

View file

@ -191,6 +191,17 @@ bool FWadFile::Open(bool quiet)
Lumps[i].Namespace = ns_global;
Lumps[i].Flags = Lumps[i].Compressed? LUMPF_COMPRESSED : 0;
Lumps[i].FullName = NULL;
// Check if the lump is within the WAD file and print a warning if not.
if (Lumps[i].Position + Lumps[i].LumpSize > wadSize || Lumps[i].Position < 0 || Lumps[i].LumpSize < 0)
{
if (Lumps[i].LumpSize != 0)
{
Printf(PRINT_HIGH, "%s: Lump %s contains invalid positioning info and will be ignored\n", Filename, Lumps[i].Name);
Lumps[i].Name[0] = 0;
}
Lumps[i].LumpSize = Lumps[i].Position = 0;
}
}
delete[] fileinfo;