(svn r1741) - Fix: added IsVehicleIndex() so it's possible to protect GetVehicle() from reading an invalid vehicle index

- Fix: added check for v->type in some commands, which expects v to be a specific type

Checks like this is needed to protect network servers from people, who hack their clients to either cheat or crash the server

NOTE: if I made a mistake here it can make a function unreachable when it should be used. Here is one place to look if something weird happens
This commit is contained in:
bjarni
2005-01-30 20:50:06 +00:00
parent fb3af3321a
commit 7d967ad12a
6 changed files with 99 additions and 27 deletions

View File

@@ -376,6 +376,14 @@ static inline Vehicle *GetVehicle(uint index)
return &_vehicles[index];
}
static inline bool IsVehicleIndex(uint index)
{
if (index < _vehicles_size)
return true;
else
return false;
}
#define FOR_ALL_VEHICLES(v) for(v = _vehicles; v != &_vehicles[_vehicles_size]; v++)
#define FOR_ALL_VEHICLES_FROM(v, from) for(v = GetVehicle(from); v != &_vehicles[_vehicles_size]; v++)