(svn r1389) -Add: [Network] Added packet protection. No longer a client or server

reads beyond the size of the packet
-Fix: [Network] A server no longer crashes when a client sends an 
invalid DoCommand, but drops the client instead.
This commit is contained in:
truelight
2005-01-05 14:39:48 +00:00
parent f1e9fdf76d
commit 523a6a1cff
8 changed files with 213 additions and 116 deletions

View File

@@ -312,6 +312,17 @@ static CommandProc * const _command_proc_table[] = {
CmdReplaceVehicle, /* 114 */
};
/* This function range-checks a cmd, and checks if the cmd is not NULL */
bool IsValidCommand(int cmd)
{
cmd = cmd & 0xFF;
if (cmd < 0 || cmd >= lengthof(_command_proc_table) || _command_proc_table[cmd] == NULL)
return false;
return true;
}
int32 DoCommandByTile(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc)
{
return DoCommand(GET_TILE_X(tile)*16, GET_TILE_Y(tile)*16, p1, p2, flags, procc);