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>
diff --git a/serialize.cpp b/serialize.cpp
index dde256a..5060c9a 100644
--- a/serialize.cpp
+++ b/serialize.cpp
@@ -78,12 +78,15 @@
             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;
             }
         }