summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Tritz <mtritz@us.ibm.com>2017-12-14 15:21:18 -0600
committerMichael Tritz <mtritz@us.ibm.com>2017-12-18 15:01:11 +0000
commit6273efd7b45453d7c268049812646afdb6ae630d (patch)
tree8150263d9c338a681710cefca2f1da39d32df443
parentee13e8318bef5724a66684ec4b3302e1725b6cb4 (diff)
downloadphosphor-bmc-code-mgmt-6273efd7b45453d7c268049812646afdb6ae630d.tar.gz
phosphor-bmc-code-mgmt-6273efd7b45453d7c268049812646afdb6ae630d.zip
Fix for priority restoration from environment variable
This fix addresses a defect in the BMC updater. When we restore the BMC version priority after a reboot, we pull it from a list of environment variables. Initially, we did so just by looking for the version ID - since that implementation, however, an additional environment variable has been added that uses the version ID. This caused the priority to sometimes be restored incorrectly, depending on the order of the variables within the file. In order to fix this defect, we search instead for "[versionID]=", which is more specific. Resolves openbmc/openbmc#2721 Change-Id: I2fd2e04c5268a63a8760ad4e3af28144583ea2dc Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
-rw-r--r--serialize.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/serialize.cpp b/serialize.cpp
index dde256a..5060c9a 100644
--- a/serialize.cpp
+++ b/serialize.cpp
@@ -78,12 +78,15 @@ bool restoreFromFile(std::string versionId, uint8_t& priority)
std::string envVars;
std::getline(input, envVars);
- if (envVars.find(versionId) != std::string::npos)
+ std::string versionVar = versionId + "=";
+ auto varPosition = envVars.find(versionVar);
+
+ if (varPosition != std::string::npos)
{
// Grab the environment variable for this versionId. These
// variables follow the format "versionId=priority\0"
- auto var = envVars.substr(envVars.find(versionId));
- priority = std::stoi(var.substr(var.find('=') + 1));
+ auto var = envVars.substr(varPosition);
+ priority = std::stoi(var.substr(versionVar.length()));
return true;
}
}
OpenPOWER on IntegriCloud