diff options
author | Nagaraju Goruganti <ngorugan@in.ibm.com> | 2018-07-10 00:47:43 -0500 |
---|---|---|
committer | Tom Joseph <tomjoseph@in.ibm.com> | 2018-07-31 04:34:53 +0000 |
commit | b898cde664f7156df348ec8558492a7732d67fe8 (patch) | |
tree | 42cef0bc466d1dbde789185c99cec673b5eb78a2 | |
parent | 79c7c85c9be3091ca79232e6bcc41f1c40071561 (diff) | |
download | phosphor-host-ipmid-b898cde664f7156df348ec8558492a7732d67fe8.tar.gz phosphor-host-ipmid-b898cde664f7156df348ec8558492a7732d67fe8.zip |
Validate Mfg Date/Time in Board Info Area
-FRU's Mfg Date/Time is the number of minutes from 0:00 hrs
1/1/96 and a 3 byte field length for Mfg Data/Time in Board Info Area.
-So max Mfg date equals to 1006632900 secs from 00:00:00 hrs 1/1/1996.
Resolves openbmc/openbmc#3202
Change-Id: I6a71b8b881b699195fee2a18b743e195fa4703a5
Signed-off-by: Nagaraju Goruganti <ngorugan@in.ibm.com>
-rw-r--r-- | ipmi_fru_info_area.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/ipmi_fru_info_area.cpp b/ipmi_fru_info_area.cpp index 1951f8c..ca3fa64 100644 --- a/ipmi_fru_info_area.cpp +++ b/ipmi_fru_info_area.cpp @@ -40,7 +40,10 @@ static constexpr uint8_t typeASCII = 0xC0; static constexpr auto maxRecordAttributeValue = 0x1F; static constexpr auto secs_from_1970_1996 = 820454400; +static constexpr auto maxMfgDateValue = 0xFFFFFF; //3 Byte length static constexpr auto secs_per_min = 60; +static constexpr auto + secsToMaxMfgdate = secs_from_1970_1996 + secs_per_min * maxMfgDateValue; /** * @brief Format Beginning of Individual IPMI FRU Data Section @@ -160,7 +163,7 @@ void appendMfgDate(const PropertyMap& propMap, FruAreaData& data) { //MFG Date/Time auto iter = propMap.find(buildDate); - if (iter != propMap.end()) + if ((iter != propMap.end()) && (iter->second.size() > 0)) { tm time = {}; strptime(iter->second.c_str(), "%F - %H:%M:%S", &time); @@ -171,7 +174,7 @@ void appendMfgDate(const PropertyMap& propMap, FruAreaData& data) // Number of minutes from 0:00 hrs 1/1/96. // LSbyte first (little endian) // 00_00_00h = unspecified." - if (raw > secs_from_1970_1996) + if ((raw >= secs_from_1970_1996) && (raw <= secsToMaxMfgdate)) { raw -= secs_from_1970_1996; raw /= secs_per_min; |