dcmihandler: update data_len to zero when getPowerReading command failed
Issue: heap data is leaked by sending the getPowerReading command
Fix: set the data_len to zero in getPowerReading command so that data is
not leaked when error occurred during getPowerReading.
Tested:
Command: FS1:\cmdtool\> cmdtool.efi 20 B0 02 DC 2c 2d 2f
Response: FF DC
Command: FS1:\cmdtool\> cmdtool.efi 20 B0 02 DC 2c 2d 2f 02 0d DC
Response: FF DC
Signed-off-by: Chalapathi Venkataramashetty <chalapathix.venkataramashetty@intel.com>
Change-Id: I33657439ffd5a632856382715e22377e18258826
diff --git a/dcmihandler.cpp b/dcmihandler.cpp
index f8498f5..cc8b6d0 100644
--- a/dcmihandler.cpp
+++ b/dcmihandler.cpp
@@ -1174,9 +1174,9 @@
ipmi_request_t request, ipmi_response_t response,
ipmi_data_len_t data_len, ipmi_context_t context)
{
+ *data_len = 0;
if (!dcmi::isDCMIPowerMgmtSupported())
{
- *data_len = 0;
log<level::ERR>("DCMI Power management is unsupported!");
return IPMI_CC_INVALID;
}