summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam A. Kennington III <william@wkennington.com>2018-05-15 11:34:44 -0700
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2018-05-29 20:36:39 +0000
commit15cd3ce7045fb4da18c0b9dc89772d9807490a54 (patch)
treea63036c347152bfb4f4055ceb441c9fd4587a98c
parentc1743fa4f561c97e1f67417486b62bdd8e54bb7d (diff)
downloadphosphor-debug-collector-15cd3ce7045fb4da18c0b9dc89772d9807490a54.zip
phosphor-debug-collector-15cd3ce7045fb4da18c0b9dc89772d9807490a54.tar.gz
Add error handling for message parsing
Some of the signals we try and parse for error logs are not structured in the format we expect when parsing. When error logging is enabled in sdbusplus this causes the phosphor-dump-manager to crash. Fix this crashing by logging errors and ignoring the bad signals. Change-Id: Ieadcb7e95f622005382f3c4957bf1535e3bb1ef9 Signed-off-by: William A. Kennington III <wak@google.com>
-rw-r--r--core_manager.cpp13
-rw-r--r--elog_watch.cpp25
2 files changed, 35 insertions, 3 deletions
diff --git a/core_manager.cpp b/core_manager.cpp
index dfa1aeb..3ab726b 100644
--- a/core_manager.cpp
+++ b/core_manager.cpp
@@ -2,6 +2,7 @@
#include <experimental/filesystem>
#include <phosphor-logging/log.hpp>
+#include <sdbusplus/exception.hpp>
#include "core_manager.hpp"
#include "config.h"
@@ -72,7 +73,17 @@ void Manager::createHelper(const vector<string>& files)
}
map<string, vector<string>> mapperResponse;
- mapperResponseMsg.read(mapperResponse);
+ try
+ {
+ mapperResponseMsg.read(mapperResponse);
+ }
+ catch (const sdbusplus::exception::SdBusError& e)
+ {
+ log<level::ERR>("Failed to parse dump create message",
+ entry("ERROR=%s", e.what()),
+ entry("REPLY_SIG=%s", mapperResponseMsg.get_signature()));
+ return;
+ }
if (mapperResponse.empty())
{
log<level::ERR>("Error reading mapper response");
diff --git a/elog_watch.cpp b/elog_watch.cpp
index 6cb7a0f..e2a3866 100644
--- a/elog_watch.cpp
+++ b/elog_watch.cpp
@@ -1,5 +1,6 @@
#include <cereal/cereal.hpp>
#include <phosphor-logging/elog.hpp>
+#include <sdbusplus/exception.hpp>
#include "elog_watch.hpp"
#include "dump_internal.hpp"
@@ -65,7 +66,17 @@ void Watch::addCallback(sdbusplus::message::message& msg)
sdbusplus::xyz::openbmc_project::Dump::Create::Error::QuotaExceeded;
LogEntryMsg logEntry;
- msg.read(logEntry);
+ try
+ {
+ msg.read(logEntry);
+ }
+ catch (const sdbusplus::exception::SdBusError& e)
+ {
+ log<level::ERR>("Failed to parse elog add signal",
+ entry("ERROR=%s", e.what()),
+ entry("REPLY_SIG=%s", msg.get_signature()));
+ return;
+ }
std::string objectPath(std::move(logEntry.first));
@@ -135,7 +146,17 @@ void Watch::addCallback(sdbusplus::message::message& msg)
void Watch::delCallback(sdbusplus::message::message& msg)
{
sdbusplus::message::object_path logEntry;
- msg.read(logEntry);
+ try
+ {
+ msg.read(logEntry);
+ }
+ catch (const sdbusplus::exception::SdBusError& e)
+ {
+ log<level::ERR>("Failed to parse elog del signal",
+ entry("ERROR=%s", e.what()),
+ entry("REPLY_SIG=%s", msg.get_signature()));
+ return;
+ }
//Get elog entry message string.
std::string objectPath(logEntry);
OpenPOWER on IntegriCloud