From 5600345375dc537216ccb13de06036798bcc9de0 Mon Sep 17 00:00:00 2001 From: Brad Bishop Date: Wed, 5 Oct 2016 21:49:19 -0400 Subject: Fix type overflow in find_sensor Signed-off-by: Brad Bishop Change-Id: I700c5847685b4432c1da42ec470860f1785b9abf --- sensorhandler.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'sensorhandler.cpp') diff --git a/sensorhandler.cpp b/sensorhandler.cpp index b3381f3..457849e 100644 --- a/sensorhandler.cpp +++ b/sensorhandler.cpp @@ -289,7 +289,8 @@ uint8_t find_sensor(uint8_t sensor_number) { dbus_interface_t a; char *p; - char r; + int r; + uint8_t type; r = find_openbmc_path("SENSOR", sensor_number, &a); @@ -303,14 +304,14 @@ uint8_t find_sensor(uint8_t sensor_number) { if (strstr(a.interface, "InventoryItem")) { // InventoryItems are real frus. So need to get the // fru_type property - r = dbus_to_sensor_type_from_dbus(&a); + type = dbus_to_sensor_type_from_dbus(&a); } else { // Non InventoryItems p = strrchr (a.path, '/'); - r = dbus_to_sensor_type(p+1); + type = dbus_to_sensor_type(p+1); } - return r; + return type; } @@ -388,6 +389,10 @@ ipmi_ret_t ipmi_sen_get_sensor_reading(ipmi_netfn_t netfn, ipmi_cmd_t cmd, } type = find_sensor(reqptr->sennum); + if(type == 0) { + fprintf(stderr, "Failed to find Sensor 0x%02x\n", reqptr->sennum); + return IPMI_CC_SENSOR_INVALID; + } fprintf(stderr, "Bus: %s, Path: %s, Interface: %s\n", a.bus, a.path, a.interface); -- cgit v1.2.1