prevent a possible buffer overflow in Cbuf_Execute (an old q1/q2 issue this was.)

git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@1245 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
sezero 2015-08-23 09:56:31 +00:00
parent 6e5ba6d525
commit ee2f39fb69

View file

@ -165,9 +165,16 @@ void Cbuf_Execute (void)
break;
}
memcpy (line, text, i);
line[i] = 0;
if (i > (int)sizeof(line) - 1)
{
memcpy (line, text, sizeof(line) - 1);
line[sizeof(line) - 1] = 0;
}
else
{
memcpy (line, text, i);
line[i] = 0;
}
// delete the text from the command buffer and move remaining commands down
// this is necessary because commands (exec, alias) can insert data at the