summaryrefslogtreecommitdiffstats
path: root/log_manager.cpp
diff options
context:
space:
mode:
authorMarri Devender Rao <devenrao@in.ibm.com>2017-11-17 05:06:25 -0600
committerMarri Devender Rao <devenrao@in.ibm.com>2017-11-19 23:53:25 -0600
commit979ed1cce24fa0cffd4fe414b8a56e17ec032b14 (patch)
treec9d2da240e2dc351d9bd7739a98bf9c5ecd5b06c /log_manager.cpp
parent8959efcb5881a1970b2057466d0267c563772208 (diff)
downloadphosphor-logging-979ed1cce24fa0cffd4fe414b8a56e17ec032b14.tar.gz
phosphor-logging-979ed1cce24fa0cffd4fe414b8a56e17ec032b14.zip
Perform sanity check while restoring error entries
Check if the data in the persisted files is valid before restoring the error entries Resolves openbmc/openbmc#2646 Change-Id: Iff0846a3366a27e59484113b7020f540087aa994 Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
Diffstat (limited to 'log_manager.cpp')
-rw-r--r--log_manager.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/log_manager.cpp b/log_manager.cpp
index fbf6682..0d8e753 100644
--- a/log_manager.cpp
+++ b/log_manager.cpp
@@ -249,6 +249,10 @@ void Manager::erase(uint32_t entryId)
void Manager::restore()
{
+ auto sanity = [](const auto& id, const auto& restoredId)
+ {
+ return id == restoredId;
+ };
std::vector<uint32_t> errorIds;
fs::path dir(ERRLOG_PERSIST_PATH);
@@ -268,13 +272,26 @@ void Manager::restore()
*this);
if (deserialize(file.path(), *e))
{
- e->emit_object_added();
- if (e->severity() >= Entry::sevLowerLimit)
+ //validate the restored error entry id
+ if (sanity(static_cast<uint32_t>(idNum), e->id()))
+ {
+ e->emit_object_added();
+ if (e->severity() >= Entry::sevLowerLimit)
+ {
+ infoErrors.push_back(idNum);
+ }
+
+ entries.insert(std::make_pair(idNum, std::move(e)));
+ errorIds.push_back(idNum);
+ }
+ else
{
- infoErrors.push_back(idNum);
+ logging::log<logging::level::ERR>(
+ "Failed in sanity check while restoring error entry. "
+ "Ignoring error entry",
+ logging::entry("ID_NUM=%d", idNum),
+ logging::entry("ENTRY_ID=%d", e->id()));
}
- entries.insert(std::make_pair(idNum, std::move(e)));
- errorIds.push_back(idNum);
}
}
OpenPOWER on IntegriCloud