psu-ng: Use regex to replace invalid VPD data
Passing non-ASCII/unprintable VPD character data to D-Bus or other
applications can lead to crashes or other unexpected behavior.
Change-Id: I9a70f4505d330652e36143395ff92902a203fa44
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
diff --git a/phosphor-power-supply/power_supply.hpp b/phosphor-power-supply/power_supply.hpp
index d60b3f0..9cdc574 100644
--- a/phosphor-power-supply/power_supply.hpp
+++ b/phosphor-power-supply/power_supply.hpp
@@ -873,7 +873,11 @@
*/
auto getMaxPowerOut() const;
- /* @brief Reads a VPD value from PMBus and corrects for size.
+ /* @brief Reads a VPD value from PMBus, correct size, and contents.
+ *
+ * If the VPD data read is not the passed in size, resize and fill with
+ * spaces. If the data contains a non-alphanumeric value, replace any of
+ * those values with spaces.
*
* @param[in] vpdName - The name of the sysfs "file" to read data from.
* @param[in] type - The HWMON file type to read from.