summaryrefslogtreecommitdiffstats
path: root/ipmi_fru_info_area.cpp
diff options
context:
space:
mode:
authorOskar Senft <osk@google.com>2018-12-07 16:13:38 -0500
committerOskar Senft <osk@google.com>2018-12-17 16:25:08 -0500
commit8b18941da3add5edb2687627f6cf9db8b19d11f6 (patch)
treee5e6bbddc17dd9eb4e1381db6315a8edd8904f57 /ipmi_fru_info_area.cpp
parent40f59e2c50572705496ae743577f124f24afd77e (diff)
downloadphosphor-host-ipmid-8b18941da3add5edb2687627f6cf9db8b19d11f6.tar.gz
phosphor-host-ipmid-8b18941da3add5edb2687627f6cf9db8b19d11f6.zip
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 <osk@google.com>
Diffstat (limited to 'ipmi_fru_info_area.cpp')
-rw-r--r--ipmi_fru_info_area.cpp17
1 files changed, 17 insertions, 0 deletions
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;
}
OpenPOWER on IntegriCloud