PEL: Fix hexdump output in peltool
Hexdump output of UserData section has 8 extra bytes that are not part
of the section data. This fix truncates the extra data to show the true
hexdump output.
Signed-off-by: Harisuddin Mohamed Isa <harisuddin@gmail.com>
Change-Id: I7c0b46fb85b94265ae4f960eb4ef36eaf293db3b
diff --git a/extensions/openpower-pels/json_utils.cpp b/extensions/openpower-pels/json_utils.cpp
index dfb6698..d45b542 100644
--- a/extensions/openpower-pels/json_utils.cpp
+++ b/extensions/openpower-pels/json_utils.cpp
@@ -72,7 +72,7 @@
const int symbolSize = 100;
std::string jsonIndent(indentLevel * indentCount, 0x20);
jsonIndent.append("\"");
- char* buffer = (char*)calloc(10 * size, sizeof(char));
+ char* buffer = (char*)calloc(std::max(70, 10 * (int)size), sizeof(char));
char* symbol = (char*)calloc(symbolSize, sizeof(char));
char ascii[17];
size_t i, j;
diff --git a/extensions/openpower-pels/pel.cpp b/extensions/openpower-pels/pel.cpp
index f94a1fc..0845aba 100644
--- a/extensions/openpower-pels/pel.cpp
+++ b/extensions/openpower-pels/pel.cpp
@@ -311,8 +311,7 @@
section.flatten(s);
std::string dstr =
dumpHex(std::data(data) + SectionHeader::flattenedSize(),
- data.size(), 2);
-
+ data.size() - SectionHeader::flattenedSize(), 2);
std::string jsonIndent(indentLevel, 0x20);
buf += jsonIndent + "\"Data\": [\n";
buf += dstr;