Parse VPD with right size

IBM VPD app now parses the VPD to its actual size or to its
maximum possible size, whichever is least.

This avoids setting fail bit during filestream read opeartion,
which happens in the case where vpd size is lesser than the
maximum possible size.

Signed-off-by: Priyanga Ramasamy <priyanga24@in.ibm.com>
Change-Id: Ida45639ab38e61cb771054ff859bfeb221f14d6d
diff --git a/ibm_vpd_app.cpp b/ibm_vpd_app.cpp
index a1ac0c6..9464405 100644
--- a/ibm_vpd_app.cpp
+++ b/ibm_vpd_app.cpp
@@ -336,13 +336,16 @@
     }
 
     // TODO: Figure out a better way to get max possible VPD size.
+    auto maxVPDSize = std::min(std::filesystem::file_size(file),
+                               static_cast<uintmax_t>(65504));
+
     Binary vpdVector;
-    vpdVector.resize(65504);
+    vpdVector.resize(maxVPDSize);
     ifstream vpdFile;
     vpdFile.open(file, ios::binary);
 
     vpdFile.seekg(offset, ios_base::cur);
-    vpdFile.read(reinterpret_cast<char*>(&vpdVector[0]), 65504);
+    vpdFile.read(reinterpret_cast<char*>(&vpdVector[0]), maxVPDSize);
     vpdVector.resize(vpdFile.gcount());
 
     return vpdVector;