Fix the String type of pendingAttributes method
When the user calls the `pendingAttributes` method, if the
`attributeType` is equal to the string type, there is a chance that
the previous logic will fail because of the `std::get<1>` exception.
Since the string type has joined `MinStringLength` and
`MaxStringLength`, it is necessary to verify the maximum length and
minimum length of the string.
resolved: https://github.com/openbmc/bios-settings-mgr/issues/2
Tested:
If the length of the hb_lid_ids attribute value we configure is 0 to
10, which is when we set a string with a length of more than 10
bytes, an exception will be thrown.
bios/string_attrs.json:
{
"attribute_name" : "hb_lid_ids",
"string_type" : "ASCII",
"minimum_string_length" : 0,
"maximum_string_length" : 10,
"default_string_length" : 0,
"default_string" : "",
"helpText" : "Provides the host a mapping of the lid IDs to human
readable names.",
"displayName" : "Hostboot Lid IDs"
}
busctl call xyz.openbmc_project.BIOSConfigManager
/xyz/openbmc_project/bios_config/manager
org.freedesktop.DBus.Properties Set ssv
xyz.openbmc_project.BIOSConfig.Manager PendingAttributes a{s\(sv\)} 1
"hb_lid_ids"
"xyz.openbmc_project.BIOSConfig.Manager.AttributeType.String" s
"123456789023"
Call failed: Invalid argument was given.
journalctl -o json-pretty SYSLOG_IDENTIFIER=biosconfig-manager
{
"_SYSTEMD_INVOCATION_ID" : "0930e3a7967e4eb68429fd472afebcec",
"_HOSTNAME" : "fp5280g2",
"_PID" : "243",
"ATTRVALUE" : "123456789023",
"_EXE" : "/usr/bin/biosconfig-manager",
"_CMDLINE" : "/usr/bin/biosconfig-manager",
"_SYSTEMD_SLICE" : "system.slice",
"SYSLOG_IDENTIFIER" : "biosconfig-manager",
"__REALTIME_TIMESTAMP" : "305445800",
"_GID" : "0",
"MINLEN" : "0",
"MAXLEN" : "10",
"CODE_LINE" : "210",
"MESSAGE" : "123456789023 Length is out of range, bound is invalid,
maxStringLength = 10, minStringLength = 0",
...
}
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Ic13a8acf8417beb92ea3ed1bec5a4bc58d3adda9
1 file changed