Fix type overflow in find_sensor
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Change-Id: I700c5847685b4432c1da42ec470860f1785b9abf
diff --git a/sensorhandler.cpp b/sensorhandler.cpp
index b3381f3..457849e 100644
--- a/sensorhandler.cpp
+++ b/sensorhandler.cpp
@@ -289,7 +289,8 @@
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 @@
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 @@
}
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);