psu-ng: Change max size of firmware version to 12
For IBM power supplies, the firmware version is read from a file created
by the device driver.
The maximum number of version bytes read from the PSU is 6. However,
the device driver formats the value as a hex string. Each byte results
in two ASCII characters. Thus, the maximum ASCII string size is 12.
Change the maximum size of this value from 6 to 12 to avoid data
truncation.
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: I92bbd5f4b4e19d96f7c9931da394d1c4186cd576
diff --git a/phosphor-power-supply/power_supply.cpp b/phosphor-power-supply/power_supply.cpp
index 35b23b2..6908260 100644
--- a/phosphor-power-supply/power_supply.cpp
+++ b/phosphor-power-supply/power_supply.cpp
@@ -859,7 +859,9 @@
// up to 8-bytes per command. The device driver only reads up to 2 bytes per
// command, but combines all three of the 2-byte reads, or all 4 of the
// 1-byte reads into one string. So, the maximum size expected is 6 bytes.
- const auto VERSION_SIZE = 6;
+ // However, it is formatted by the driver as a hex string with two ASCII
+ // characters per byte. So the maximum ASCII string size is 12.
+ const auto VERSION_SIZE = 12;
using PropertyMap =
std::map<std::string,