(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:
@@ -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++)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user