ipmiUserSetUserName argument change
ipmiUserSetUserName accepts a const char* that it converts to a
std::string using a maximum of ipmiMaxUserName to be able to safely
handle non-null terminated names.
Tested:
builds and runs as expected
Change-Id: Id8b02216fe9a3572e87f133ae6bfc1f3565c660d
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/src/oemcommands.cpp b/src/oemcommands.cpp
index 580bfd5..515a539 100644
--- a/src/oemcommands.cpp
+++ b/src/oemcommands.cpp
@@ -1088,10 +1088,11 @@
PrivAccess privAccess = {0, true, true, true, PRIVILEGE_ADMIN};
#endif
- const std::string strUserName(
- reinterpret_cast<const char*>(userName.data()));
+ // ipmiUserSetUserName correctly handles char*, possibly non-null
+ // terminated strings using ipmiMaxUserName size
+ auto userNameRaw = reinterpret_cast<const char*>(userName.data());
- if (ipmi::ccSuccess == ipmiUserSetUserName(ipmiDefaultUserId, strUserName))
+ if (ipmi::ccSuccess == ipmiUserSetUserName(ipmiDefaultUserId, userNameRaw))
{
if (ipmi::ccSuccess ==
ipmiUserSetUserPassword(