legacy handlers need a bigger buffer
In the original ipmi execution queue, handlers were passed a larger
buffer. The current code was only passing in the configured channel
size, or 64 if no size was configured. This is too small and leads
to buffer overflows for responses greater than 64 bytes.
This brings the buffer sizes up to a point that matches the legacy
code and to a size that is larger than any of IPMI standard transport
sizes.
Tested: used a bogus handler to create a large response and found that
the entire response was returned.
Change-Id: I91b359812247ae5fdef105c7b7a9dfe003548494
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/include/ipmid/handler.hpp b/include/ipmid/handler.hpp
index 53b0bb8..10b7119 100644
--- a/include/ipmid/handler.hpp
+++ b/include/ipmid/handler.hpp
@@ -267,6 +267,7 @@
};
#ifdef ALLOW_DEPRECATED_API
+static constexpr size_t maxLegacyBufferSize = 64 * 1024;
/**
* @brief Legacy IPMI handler class
*
@@ -311,8 +312,7 @@
{
message::Response::ptr response = request->makeResponse();
// allocate a big response buffer here
- response->payload.resize(
- getChannelMaxTransferSize(request->ctx->channel));
+ response->payload.resize(maxLegacyBufferSize);
size_t len = request->payload.size() - request->payload.rawIndex;
Cc ccRet{ccSuccess};
@@ -401,8 +401,7 @@
{
message::Response::ptr response = request->makeResponse();
// allocate a big response buffer here
- response->payload.resize(
- getChannelMaxTransferSize(request->ctx->channel));
+ response->payload.resize(maxLegacyBufferSize);
size_t len = request->payload.size() - request->payload.rawIndex;
Cc ccRet{ccSuccess};