FRU: Fix response for Read FRU Data Command
1) Add the count field as part of read fru command response.
2) Fix in copying the data from the offset.
Change-Id: I2eaa76e82179ad65ba3af0f1795aeec40e68a0fc
Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
diff --git a/storagehandler.cpp b/storagehandler.cpp
index 9052b6f..6ae2f91 100644
--- a/storagehandler.cpp
+++ b/storagehandler.cpp
@@ -651,9 +651,17 @@
entry("SIZE_OF_FRU_AREA=%s", size));
return IPMI_CC_INVALID;
}
- std::copy((fruArea.begin() + offset), (fruArea.begin() + reqptr->count),
- (static_cast<uint8_t*>(response)));
- *data_len = reqptr->count;
+
+ // Write the count of requested data.
+ auto buff = static_cast<uint8_t *>(response);
+ *buff = reqptr->count;
+ buff++;
+
+ std::copy((fruArea.begin() + offset),
+ (fruArea.begin() + offset + reqptr->count),
+ buff);
+
+ *data_len = reqptr->count + 1; // additional one byte for count
}
catch (const InternalFailure& e)
{