From 5b56182b9699074dd77551a13069e978e81a9c68 Mon Sep 17 00:00:00 2001 From: Matt Spinler Date: Wed, 12 Feb 2020 16:05:51 -0600 Subject: PEL: Sanitize the SRC ASCII string field 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 Change-Id: I7afe64e199ebd2448b54e4ba5769de436d30b9ba --- extensions/openpower-pels/ascii_string.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) 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 -- cgit v1.2.1