summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Joseph <tomjoseph@in.ibm.com>2018-03-29 13:49:06 +0530
committerTom Joseph <tomjoseph@in.ibm.com>2018-04-23 14:47:42 +0530
commit187f564a35235d38a59af3dfb18bb76883851d30 (patch)
treeac3f65f295614a1c8d3915d1ac458365e1ec494d
parentd8249ee08eacba135a98c0d9294b88a1fe116bec (diff)
downloadphosphor-host-ipmid-187f564a35235d38a59af3dfb18bb76883851d30.tar.gz
phosphor-host-ipmid-187f564a35235d38a59af3dfb18bb76883851d30.zip
Check if the FRU Id is valid for FRU commands
Validate FRU Id before proceesing with the command handling. Do not report error log for any FRU command failure, since IPMI is an external interface. Resolves openbmc/openbmc#3016 Change-Id: I9e2af3ce50285662f1b8f9600222e9ff3057a7e3 Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
-rw-r--r--storagehandler.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/storagehandler.cpp b/storagehandler.cpp
index d1392e6..6f97bef 100644
--- a/storagehandler.cpp
+++ b/storagehandler.cpp
@@ -595,6 +595,14 @@ ipmi_ret_t ipmi_storage_get_fru_inv_area_info(
ipmi_ret_t rc = IPMI_CC_OK;
const FruInvenAreaInfoRequest* reqptr =
reinterpret_cast<const FruInvenAreaInfoRequest*>(request);
+
+ auto iter = frus.find(reqptr->fruID);
+ if (iter == frus.end())
+ {
+ *data_len = 0;
+ return IPMI_CC_SENSOR_INVALID;
+ }
+
try
{
const auto& fruArea = getFruAreaData(reqptr->fruID);
@@ -614,7 +622,6 @@ ipmi_ret_t ipmi_storage_get_fru_inv_area_info(
rc = IPMI_CC_UNSPECIFIED_ERROR;
*data_len = 0;
log<level::ERR>(e.what());
- report<InternalFailure>();
}
return rc;
}
@@ -630,6 +637,14 @@ ipmi_ret_t ipmi_storage_read_fru_data(
reinterpret_cast<const ReadFruDataRequest*>(request);
auto resptr =
reinterpret_cast<ReadFruDataResponse*>(response);
+
+ auto iter = frus.find(reqptr->fruID);
+ if (iter == frus.end())
+ {
+ *data_len = 0;
+ return IPMI_CC_SENSOR_INVALID;
+ }
+
auto offset =
static_cast<uint16_t>(reqptr->offsetMS << 8 | reqptr->offsetLS);
try
@@ -658,7 +673,6 @@ ipmi_ret_t ipmi_storage_read_fru_data(
rc = IPMI_CC_UNSPECIFIED_ERROR;
*data_len = 0;
log<level::ERR>(e.what());
- report<InternalFailure>();
}
return rc;
}
OpenPOWER on IntegriCloud