summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2019-04-24 01:57:36 -0700
committerWilliam A. Kennington III <wak@google.com>2019-04-29 12:06:35 -0700
commitd10d90563e58606964fe3b8460eed2ca719527e5 (patch)
treeb0407871f01e1d50822a45b89cc681a31895533c
parentf2fd17a41bf7e3afd4d69adf5f8ea5642bdfffcf (diff)
downloadphosphor-host-ipmid-d10d90563e58606964fe3b8460eed2ca719527e5.tar.gz
phosphor-host-ipmid-d10d90563e58606964fe3b8460eed2ca719527e5.zip
ipmid: Fix group / OEM parsing
The types of the fields being unpacked are larger than what the spec requires for the sizing. This means our unpacker tries to unpack 4 bytes for the group (which is supposed to be 1 byte) and 4 bytes for the oem (which is only 3 bytes). This breaks oem commands that take no arguments since our parser will reject those commands for being too short. It also breaks the response, since it adds more bytes than needed. Change-Id: I4f4710a6a2720574efb86635827f737be48d296a Signed-off-by: William A. Kennington III <wak@google.com>
-rw-r--r--ipmid-new.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/ipmid-new.cpp b/ipmid-new.cpp
index 2654d61..97c6e79 100644
--- a/ipmid-new.cpp
+++ b/ipmid-new.cpp
@@ -271,19 +271,20 @@ message::Response::ptr executeIpmiCommandCommon(
message::Response::ptr executeIpmiGroupCommand(message::Request::ptr request)
{
// look up the group for this request
- Group group;
- if (0 != request->payload.unpack(group))
+ uint8_t bytes;
+ if (0 != request->payload.unpack(bytes))
{
return errorResponse(request, ccReqDataLenInvalid);
}
// The handler will need to unpack group as well; we just need it for lookup
request->payload.reset();
+ auto group = static_cast<Group>(bytes);
message::Response::ptr response =
executeIpmiCommandCommon(groupHandlerMap, group, request);
// if the handler should add the group; executeIpmiCommandCommon does not
if (response->cc != ccSuccess && response->payload.size() == 0)
{
- response->pack(group);
+ response->pack(bytes);
}
return response;
}
@@ -291,18 +292,19 @@ message::Response::ptr executeIpmiGroupCommand(message::Request::ptr request)
message::Response::ptr executeIpmiOemCommand(message::Request::ptr request)
{
// look up the iana for this request
- Iana iana;
- if (0 != request->payload.unpack(iana))
+ uint24_t bytes;
+ if (0 != request->payload.unpack(bytes))
{
return errorResponse(request, ccReqDataLenInvalid);
}
request->payload.reset();
+ auto iana = static_cast<Iana>(bytes);
message::Response::ptr response =
executeIpmiCommandCommon(oemHandlerMap, iana, request);
// if the handler should add the iana; executeIpmiCommandCommon does not
if (response->cc != ccSuccess && response->payload.size() == 0)
{
- response->pack(iana);
+ response->pack(bytes);
}
return response;
}
OpenPOWER on IntegriCloud