summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2020-02-12 16:05:51 -0600
committerMatt Spinler <spinler@us.ibm.com>2020-02-17 17:19:10 +0000
commit5b56182b9699074dd77551a13069e978e81a9c68 (patch)
tree90e724224b1cb17aec3efa5b9e140f0008ff2646
parent945299f077adb1b138b6507d1a3943415d6c2079 (diff)
downloadphosphor-logging-master.tar.gz
phosphor-logging-master.zip
PEL: Sanitize the SRC ASCII string fieldHEADmaster
This field may be displayed by things like a web UI and LCD panel, so on unflattening convert any disallowed characters to a space. Only allow: alphanumeric, '.', ':', '/', ' '. When a host PEL is received, the PEL will be unflattened and reflattened when the commit timestamp and PLID are modified, and this will be fixed up then. This matches other service processor implementations that dealt with PELs. Signed-off-by: Matt Spinler <spinler@us.ibm.com> Change-Id: I7afe64e199ebd2448b54e4ba5769de436d30b9ba
-rw-r--r--extensions/openpower-pels/ascii_string.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/extensions/openpower-pels/ascii_string.cpp b/extensions/openpower-pels/ascii_string.cpp
index 124bd0c..7d4d4f3 100644
--- a/extensions/openpower-pels/ascii_string.cpp
+++ b/extensions/openpower-pels/ascii_string.cpp
@@ -73,6 +73,15 @@ void AsciiString::flatten(Stream& stream) const
void AsciiString::unflatten(Stream& stream)
{
stream.read(_string.data(), _string.size());
+
+ // Only allow certain ASCII characters as other entities will
+ // eventually want to display this.
+ std::for_each(_string.begin(), _string.end(), [](auto& c) {
+ if (!isalnum(c) && (c != ' ') && (c != '.') && (c != ':') && (c != '/'))
+ {
+ c = ' ';
+ }
+ });
}
std::string AsciiString::get() const
OpenPOWER on IntegriCloud