From 73c0cc5203ee748b4b38046ae7a53e4aa138cdd2 Mon Sep 17 00:00:00 2001 From: bjarni Date: Sun, 30 Jan 2005 20:50:06 +0000 Subject: (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 --- vehicle.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'vehicle.h') diff --git a/vehicle.h b/vehicle.h index 2a069e8b1..8c626908a 100644 --- a/vehicle.h +++ b/vehicle.h @@ -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++) -- cgit v1.2.3-54-g00ecf