mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-30 16:00:55 +00:00
- Fixed: The Dehacked parser could read past the end of the file if the last
element was improperly defined. SVN r2035 (trunk)
This commit is contained in:
parent
00447b8f44
commit
cc3b7967a1
2 changed files with 17 additions and 10 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
December 20, 2009 (Changes by Graf Zahl)
|
||||||
|
- Fixed: The Dehacked parser could read past the end of the file if the last
|
||||||
|
element was improperly defined.
|
||||||
|
|
||||||
December 19, 2009
|
December 19, 2009
|
||||||
- Extended MF3_SKYEXPLODE to apply to horizon walls as well.
|
- Extended MF3_SKYEXPLODE to apply to horizon walls as well.
|
||||||
|
|
||||||
|
|
|
@ -252,6 +252,7 @@ DehSpriteMappings[] =
|
||||||
#define CHECKKEY(a,b) if (!stricmp (Line1, (a))) (b) = atoi(Line2);
|
#define CHECKKEY(a,b) if (!stricmp (Line1, (a))) (b) = atoi(Line2);
|
||||||
|
|
||||||
static char *PatchFile, *PatchPt, *PatchName;
|
static char *PatchFile, *PatchPt, *PatchName;
|
||||||
|
static int PatchSize;
|
||||||
static char *Line1, *Line2;
|
static char *Line1, *Line2;
|
||||||
static int dversion, pversion;
|
static int dversion, pversion;
|
||||||
static bool including, includenotext;
|
static bool including, includenotext;
|
||||||
|
@ -427,7 +428,7 @@ static bool ReadChars (char **stuff, int size)
|
||||||
size++;
|
size++;
|
||||||
|
|
||||||
PatchPt++;
|
PatchPt++;
|
||||||
} while (--size);
|
} while (--size && *PatchPt != 0);
|
||||||
|
|
||||||
*str = 0;
|
*str = 0;
|
||||||
return true;
|
return true;
|
||||||
|
@ -524,7 +525,7 @@ static char *igets (void)
|
||||||
{
|
{
|
||||||
char *line;
|
char *line;
|
||||||
|
|
||||||
if (*PatchPt == '\0')
|
if (*PatchPt == '\0' || PatchPt >= PatchFile + PatchSize )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
line = PatchPt;
|
line = PatchPt;
|
||||||
|
@ -2205,7 +2206,7 @@ static int DoInclude (int dummy)
|
||||||
{
|
{
|
||||||
char *data;
|
char *data;
|
||||||
int savedversion, savepversion;
|
int savedversion, savepversion;
|
||||||
char *savepatchfile, *savepatchpt, *savepatchname;
|
char *savepatchfile, *savepatchpt, *savepatchname, savepatchsize;
|
||||||
|
|
||||||
if (including)
|
if (including)
|
||||||
{
|
{
|
||||||
|
@ -2239,6 +2240,7 @@ static int DoInclude (int dummy)
|
||||||
savepatchname = PatchName;
|
savepatchname = PatchName;
|
||||||
savepatchfile = PatchFile;
|
savepatchfile = PatchFile;
|
||||||
savepatchpt = PatchPt;
|
savepatchpt = PatchPt;
|
||||||
|
savepatchsize = PatchSize;
|
||||||
savedversion = dversion;
|
savedversion = dversion;
|
||||||
savepversion = pversion;
|
savepversion = pversion;
|
||||||
including = true;
|
including = true;
|
||||||
|
@ -2272,6 +2274,7 @@ static int DoInclude (int dummy)
|
||||||
PatchName = savepatchname;
|
PatchName = savepatchname;
|
||||||
PatchFile = savepatchfile;
|
PatchFile = savepatchfile;
|
||||||
PatchPt = savepatchpt;
|
PatchPt = savepatchpt;
|
||||||
|
PatchSize = savepatchsize;
|
||||||
dversion = savedversion;
|
dversion = savedversion;
|
||||||
pversion = savepversion;
|
pversion = savepversion;
|
||||||
}
|
}
|
||||||
|
@ -2294,12 +2297,12 @@ int D_LoadDehLumps()
|
||||||
|
|
||||||
bool D_LoadDehLump(int lumpnum)
|
bool D_LoadDehLump(int lumpnum)
|
||||||
{
|
{
|
||||||
int filelen = Wads.LumpLength(lumpnum);
|
PatchSize = Wads.LumpLength(lumpnum);
|
||||||
|
|
||||||
PatchName = copystring(Wads.GetLumpFullPath(lumpnum));
|
PatchName = copystring(Wads.GetLumpFullPath(lumpnum));
|
||||||
PatchFile = new char[filelen + 1];
|
PatchFile = new char[PatchSize + 1];
|
||||||
Wads.ReadLump(lumpnum, PatchFile);
|
Wads.ReadLump(lumpnum, PatchFile);
|
||||||
PatchFile[filelen] = '\0'; // terminate with a '\0' character
|
PatchFile[PatchSize] = '\0'; // terminate with a '\0' character
|
||||||
return DoDehPatch();
|
return DoDehPatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2310,13 +2313,13 @@ bool D_LoadDehFile(const char *patchfile)
|
||||||
deh = fopen(patchfile, "rb");
|
deh = fopen(patchfile, "rb");
|
||||||
if (deh != NULL)
|
if (deh != NULL)
|
||||||
{
|
{
|
||||||
int filelen = Q_filelength(deh);
|
PatchSize = Q_filelength(deh);
|
||||||
|
|
||||||
PatchName = copystring(patchfile);
|
PatchName = copystring(patchfile);
|
||||||
PatchFile = new char[filelen + 1];
|
PatchFile = new char[PatchSize + 1];
|
||||||
fread(PatchFile, 1, filelen, deh);
|
fread(PatchFile, 1, PatchSize, deh);
|
||||||
fclose(deh);
|
fclose(deh);
|
||||||
PatchFile[filelen] = '\0'; // terminate with a '\0' character
|
PatchFile[PatchSize] = '\0'; // terminate with a '\0' character
|
||||||
return DoDehPatch();
|
return DoDehPatch();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue