Added lump size validation to the WAD loader

This commit is contained in:
Christoph Oelckers 2018-06-27 08:51:45 +02:00
parent 0ed1077f29
commit cbe4c9c5c1

View file

@ -188,6 +188,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;