summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>2019-01-04 16:42:22 +0530
committerRichard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>2019-01-17 16:49:38 +0000
commit23df06f44f2b852c90a4abed8a562bf53e056d54 (patch)
tree8116062d460de016e9ce561a68328f14f9c06d99
parent583171207c4f9a091abe3f867cc415e7f9aa514b (diff)
downloadphosphor-host-ipmid-23df06f44f2b852c90a4abed8a562bf53e056d54.tar.gz
phosphor-host-ipmid-23df06f44f2b852c90a4abed8a562bf53e056d54.zip
Return error for password length bit mismatch
Return InvalidLength error, for password length bit mismatch for Set User Password command. i.e. if length is specified as 16 then accept only 16 byte charachers and for length specified as 20 accept 20 byte characters Unit-test: 1. Verified both by issuing proper 20 & 16 byte length filed 2. Also verified error sending 20 character byte by setting 16 byte length Change-Id: I1e6cca3b4dcd920e8e8dfcf23344c10d1bf37ca2 Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
-rw-r--r--user_channel/usercommands.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/user_channel/usercommands.cpp b/user_channel/usercommands.cpp
index d901e2c..eb770e4 100644
--- a/user_channel/usercommands.cpp
+++ b/user_channel/usercommands.cpp
@@ -37,6 +37,8 @@ static constexpr uint8_t disableUser = 0x00;
static constexpr uint8_t enableUser = 0x01;
static constexpr uint8_t setPassword = 0x02;
static constexpr uint8_t testPassword = 0x03;
+static constexpr uint8_t passwordKeySize20 = 1;
+static constexpr uint8_t passwordKeySize16 = 0;
/** @struct SetUserAccessReq
*
@@ -432,9 +434,12 @@ ipmi_ret_t ipmiSetUserPassword(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
return IPMI_CC_REQ_DATA_LEN_INVALID;
}
// If set / test password then password length has to be 16 or 20 bytes
+ // based on the password size bit.
if (((req->operation == setPassword) || (req->operation == testPassword)) &&
- ((passwordLength != maxIpmi20PasswordSize) &&
- (passwordLength != maxIpmi15PasswordSize)))
+ (((req->ipmi20 == passwordKeySize20) &&
+ (passwordLength != maxIpmi20PasswordSize)) ||
+ ((req->ipmi20 == passwordKeySize16) &&
+ (passwordLength != maxIpmi15PasswordSize))))
{
log<level::DEBUG>("Invalid Length");
return IPMI_CC_REQ_DATA_LEN_INVALID;
OpenPOWER on IntegriCloud