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>
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 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 @@
 {
     //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 @@
         // 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;