diff options
author | Brad Bishop <bradleyb@us.ibm.com> | 2016-10-05 21:49:19 -0400 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2016-10-06 15:26:24 +0000 |
commit | 5600345375dc537216ccb13de06036798bcc9de0 (patch) | |
tree | 00c0007abce57f20053e9704671a948f341f300a /sensorhandler.cpp | |
parent | 819ddd42e387db5dfa545a36663fe30146a6df7b (diff) | |
download | phosphor-host-ipmid-5600345375dc537216ccb13de06036798bcc9de0.tar.gz phosphor-host-ipmid-5600345375dc537216ccb13de06036798bcc9de0.zip |
Fix type overflow in find_sensor
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Change-Id: I700c5847685b4432c1da42ec470860f1785b9abf
Diffstat (limited to 'sensorhandler.cpp')
-rw-r--r-- | sensorhandler.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
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); |