Fix a FruDevice service crash issue
In some systems, the FruDevice service stopped while it is adding
Dbus properties with below logs:
Mar 19 17:17:38 wolfpass systemd[1]: Starting Fru Device...
Mar 19 17:17:38 wolfpass fru-device[1061]: failed to read bus 5 address 112
Mar 19 17:18:04 wolfpass fru-device[1061]: failed to read bus 5 address 112
Mar 19 17:18:18 wolfpass fru-device[1061]: process 1061: arguments to dbus_message_iter_append_basic() were incorrect, asserti
on "_dbus_check_is_valid_utf8 (*string_p)" failed in file ../../dbus-1.10.10/dbus/dbus-message.c line 2749.
Mar 19 17:18:18 wolfpass fru-device[1061]: This is normally a bug in some application using the D-Bus library.
Mar 19 17:18:18 wolfpass fru-device[1061]: D-Bus not built with -rdynamic so unable to print a backtrace
Mar 19 17:18:28 wolfpass systemd[1]: [[0;1;39mxyz.openbmc_project.FruDevice.service: Main process exited, code=killed, status=
6/ABRT[[0m
Mar 19 17:18:28 wolfpass systemd[1]: [[0;1;31mFailed to start Fru Device.[[0m
Mar 19 17:18:28 wolfpass systemd[1]: [[0;1;39mxyz.openbmc_project.FruDevice.service: Unit entered failed state.[[0m
Mar 19 17:18:28 wolfpass systemd[1]: [[0;1;39mxyz.openbmc_project.FruDevice.service: Failed with result 'signal'.[[0m
This is caused by an invalid string property from some components
so this patch adds a regex_replace() call to avoid _dbus_assert
crashes.
Change-Id: I551f12f028e08685ce5dbb3a3f770d199ff8fc3b
Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@intel.com>
diff --git a/src/EntityManager.cpp b/src/EntityManager.cpp
index c9d0c15..eb7f90a 100644
--- a/src/EntityManager.cpp
+++ b/src/EntityManager.cpp
@@ -373,7 +373,7 @@
}
std::string commandStr = *(match.begin() + 1);
// convert single ticks and single slashes into legal json
- boost::replace_all(commandStr, "'", R"(")");
+ boost::replace_all(commandStr, "'", "\"");
boost::replace_all(commandStr, R"(\)", R"(\\)");
auto json = nlohmann::json::parse(commandStr, nullptr, false);
if (json.is_discarded())