From 8b18941da3add5edb2687627f6cf9db8b19d11f6 Mon Sep 17 00:00:00 2001 From: Oskar Senft Date: Fri, 7 Dec 2018 16:13:38 -0500 Subject: ipmi_fru_info_area: Pad output buffer. Always pad the output buffer to the maximum IPMI FRU size. This enables tools like ipmitool to write a new FRU blob with data longer than the original payload. Change-Id: Id6eb2c80504fb42ac72d7b643d186e9641a0832c Signed-off-by: Oskar Senft --- ipmi_fru_info_area.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'ipmi_fru_info_area.cpp') diff --git a/ipmi_fru_info_area.cpp b/ipmi_fru_info_area.cpp index e10eee5..089a7cb 100644 --- a/ipmi_fru_info_area.cpp +++ b/ipmi_fru_info_area.cpp @@ -46,6 +46,16 @@ static constexpr auto secs_per_min = 60; static constexpr auto secsToMaxMfgdate = secs_from_1970_1996 + secs_per_min * maxMfgDateValue; +// Minimum size of resulting FRU blob. +// This is also the theoretical maximum size according to the spec: +// 8 bytes header + 5 areas at 0xff*8 bytes max each +// 8 + 5*0xff*8 = 0x27e0 +static constexpr auto fruMinSize = 0x27E0; + +// Value to use for padding. +// Using 0xff to match the default (blank) value in a physical EEPROM. +static constexpr auto fruPadValue = 0xff; + /** * @brief Format Beginning of Individual IPMI FRU Data Section * @@ -427,6 +437,13 @@ FruAreaData buildFruAreaData(const FruInventoryData& inventory) // add product use area data combFruArea.insert(combFruArea.end(), prodArea.begin(), prodArea.end()); + // If area is smaller than the minimum size, pad it. This enables ipmitool + // to update the FRU blob with values longer than the original payload. + if (combFruArea.size() < fruMinSize) + { + combFruArea.resize(fruMinSize, fruPadValue); + } + return combFruArea; } -- cgit v1.2.1