Fix a potential out-of-bounds read and write when loading the help file

in Mapster32.

git-svn-id: https://svn.eduke32.com/eduke32@2161 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2011-12-09 19:09:14 +00:00
parent d806bc9fea
commit c112cdde89

View file

@ -2018,7 +2018,8 @@ static void ReadHelpFile(const char *name)
if (charsread>0) if (charsread>0)
{ {
tempbuf[charsread-1]=0; tempbuf[charsread-1]=0;
if (tempbuf[charsread-2]==0x0d) tempbuf[charsread-2]=0; if (charsread>=2 && tempbuf[charsread-2]==0x0d)
tempbuf[charsread-2]=0;
} }
Bmemcpy(hp->line[j], tempbuf, 80); Bmemcpy(hp->line[j], tempbuf, 80);