Fix for set/get cold redundancy configuration commands

In set, the length of input parameters should be the same as the connected PSUs;
In get, the length of the return value should be the same as the connected PSUs;

Tested:
On system with two PSUs:

ipmitool raw 0x30 0x2e 5
 05 02

ipmitool raw 0x30 0x2d 0x03 0x01 0x01 0x02
 00
ipmitool raw 0x30 0x2e 3
 03 01 01 02

ipmitool raw 0x30 0x2d 0x03 0x01 0x01 0x02 0x3
Unable to send RAW command (channel=0x0 netfn=0x30 lun=0x0 cmd=0x2d rsp=0xc7): Request data length invalid

ipmitool raw 0x30 0x2d 0x03 0x01 0x01
Unable to send RAW command (channel=0x0 netfn=0x30 lun=0x0 cmd=0x2d rsp=0xc7): Request data length invalid

Signed-off-by: Yong Li <yong.b.li@linux.intel.com>
Change-Id: I3352d7aa197af63925569ef1758132914d18eaa8
diff --git a/src/oemcommands.cpp b/src/oemcommands.cpp
index 00f6943..9e7e841 100644
--- a/src/oemcommands.cpp
+++ b/src/oemcommands.cpp
@@ -2109,7 +2109,7 @@
                 {
                     ipmi::responseReqDataLenInvalid();
                 }
-                if (rankOrder.size() < numberOfPSU)
+                if (rankOrder.size() != numberOfPSU)
                 {
                     return ipmi::responseReqDataLenInvalid();
                 }
@@ -2171,7 +2171,7 @@
     return ipmi::responseSuccess(crSetCompleted);
 }
 
-ipmi::RspType<uint8_t, std::variant<uint8_t, uint32_t, std::array<uint8_t, 5>>>
+ipmi::RspType<uint8_t, std::variant<uint8_t, uint32_t, std::vector<uint8_t>>>
     ipmiOEMGetCRConfig(ipmi::Context::ptr ctx, uint8_t parameter)
 {
     crConfigVariant value;
@@ -2256,17 +2256,18 @@
                     "Error to get RotationAlgorithm property");
                 return ipmi::responseResponseError();
             }
-            std::array<uint8_t, 5> response = {0, 0, 0, 0, 0};
+            std::vector<uint8_t> response;
             namespace server = sdbusplus::xyz::openbmc_project::Control::server;
             auto algo =
                 server::PowerSupplyRedundancy::convertAlgoFromString(*pAlgo);
+
             switch (algo)
             {
                 case server::PowerSupplyRedundancy::Algo::bmcSpecific:
-                    response[0] = 0;
+                    response.push_back(0);
                     break;
                 case server::PowerSupplyRedundancy::Algo::userSpecific:
-                    response[0] = 1;
+                    response.push_back(1);
                     break;
                 default:
                     phosphor::logging::log<phosphor::logging::level::ERR>(
@@ -2286,14 +2287,10 @@
                     "Error to get RotationRankOrder property");
                 return ipmi::responseResponseError();
             }
-            if (pResponse->size() + 1 > response.size())
-            {
-                phosphor::logging::log<phosphor::logging::level::ERR>(
-                    "Incorrect size of RotationAlgorithm property");
-                return ipmi::responseResponseError();
-            }
+
             std::copy(pResponse->begin(), pResponse->end(),
-                      response.begin() + 1);
+                      std::back_inserter(response));
+
             return ipmi::responseSuccess(parameter, response);
         }
         case crParameter::rotationPeriod: