Fix for restoreFromFile cereal exception
This commit provides a fix for an issue in which the cereal
restoreFromFile() would crash the host software updater in the event
that a priority persistence file is empty.
Resolves openbmc/openbmc#2091
Change-Id: Icca5d68ef250e2662cd02075c6ba731e4ab768b0
Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
diff --git a/item_updater.cpp b/item_updater.cpp
index d022c96..0f583ed 100755
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -194,23 +194,18 @@
// If Active, create RedundancyPriority instance for this version.
if (activationState == server::Activation::Activations::Active)
{
- if(fs::is_regular_file(PERSIST_DIR + id))
+ uint8_t priority = std::numeric_limits<uint8_t>::max();
+ if (!restoreFromFile(id, priority))
{
- uint8_t priority;
- restoreFromFile(id, &priority);
- activations.find(id)->second->redundancyPriority =
- std::make_unique<RedundancyPriority>(
- bus,
- path,
- *(activations.find(id)->second),
- priority);
+ log<level::ERR>("Unable to restore priority from file.",
+ entry("VERSIONID=%s", id));
}
- else
- {
- activations.find(id)->second->activation(
- server::Activation::Activations::Invalid);
- }
-
+ activations.find(id)->second->redundancyPriority =
+ std::make_unique<RedundancyPriority>(
+ bus,
+ path,
+ *(activations.find(id)->second),
+ priority);
}
// Create Version instance for this version.