netipmid: Handle invalid length for getPayloadInfo
Invalid length error check added for getPayloadInfo command
Tested:
1.Verified negative case by providing improper length
ipmitool -I lanplus -H <ip-addr> -U <user> -P <passwd> raw 0x06 0x4b 0x01 0x01 0x00
Unable to send RAW command (channel=0x0 netfn=0x6 lun=0x0 cmd=0x4b rsp=0xc7):
Request data length invalid //response
2.Verified normal case and output is same
ipmitool -I lanplus -H <ip-addr> -U <user> -P <passwd> raw 0x06 0x4b 0x01 0x01
00 00 00 00 00 00 00 00 00 00 00 00 //response
Signed-off-by: anil kumar appana <anil.kumarx.appana@intel.com>
Change-Id: I5d03e1703dc3bcf6503bfcfdbebc9fc4c29074be
diff --git a/command/payload_cmds.cpp b/command/payload_cmds.cpp
index 683d21a..fb207ac 100644
--- a/command/payload_cmds.cpp
+++ b/command/payload_cmds.cpp
@@ -218,6 +218,11 @@
auto response =
reinterpret_cast<GetPayloadInfoResponse*>(outPayload.data());
+ if (inPayload.size() != sizeof(GetPayloadInfoRequest))
+ {
+ response->completionCode = IPMI_CC_REQ_DATA_LEN_INVALID;
+ return outPayload;
+ }
// SOL is the payload currently supported for payload status & only one
// instance of SOL is supported.
if (static_cast<uint8_t>(message::PayloadType::SOL) !=
@@ -227,7 +232,6 @@
response->completionCode = IPMI_CC_INVALID_FIELD_REQUEST;
return outPayload;
}
-
auto status = std::get<sol::Manager&>(singletonPool)
.isPayloadActive(request->payloadInstance);