From 17d812fec1b76fb6042e10067e34eb296bc5280b Mon Sep 17 00:00:00 2001 From: Jeremy Tan Date: Wed, 4 Sep 2013 20:04:41 +0800 Subject: [PATCH] Fix segfault and bounds checking on sensor queries --- server/sensor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/sensor.c b/server/sensor.c index 8115a3b..2e0749e 100644 --- a/server/sensor.c +++ b/server/sensor.c @@ -12,7 +12,7 @@ /** Array of sensors, initialised by Sensor_Init **/ static Sensor g_sensors[NUMSENSORS]; //global to this file -static const char * g_sensor_names[] = {"analog_test0","analog_test1","digital_test0"}; +static const char * g_sensor_names[] = {"analog_test0","analog_test1","digital_test0","digital_test1"}; /** * Read a data value from a sensor; block until value is read * @param sensor_id - The ID of the sensor @@ -195,7 +195,7 @@ Sensor * Sensor_Identify(const char * id_str) return NULL; } // Bounds check - if (id < 0 || id > NUMSENSORS) + if (id < 0 || id >= NUMSENSORS) return NULL; -- 2.20.1