manager: add hard-coded read checks
The host-client cannot try to read back more than this number of bytes
without hitting a memory overflow in phosphor-host-ipmid. The method we
can call to dynamically receive that number isn't currently linking out
of the userlayer library.
Note: Once the configure_ac can find and provide the userlayer library
from phosphor-host-ipmid, we can remove the hard-coded 64 and 0xe.
Change-Id: I08f6bb59ce44279f76a494dccaa477ae75d532c4
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/manager.cpp b/manager.cpp
index 712d7db..639ca2d 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -270,8 +270,23 @@
return std::vector<uint8_t>();
}
+ /* TODO: Currently, configure_ac isn't finding libuserlayer, w.r.t the
+ * symbols I need.
+ */
+
+ /** The channel to use for now.
+ * TODO: We will receive this information through the IPMI message call.
+ */
+ // const int ipmiChannel = ipmi::currentChNum;
+ /** This information is transport specific.
+ * TODO: We need a way to know this dynamically.
+ * on BT, 4 bytes of header, and 1 reply code.
+ */
+ // uint32_t maxTransportSize = ipmi::getChannelMaxTransferSize(ipmiChannel);
+
/* Try reading from it. */
- return info->handler->read(session, offset, requestedSize);
+ return info->handler->read(session, offset,
+ std::min(maximumReadSize, requestedSize));
}
bool BlobManager::write(uint16_t session, uint32_t offset,