Skip to content

Commit ed2551d

Browse files
committed
vpd-tool: fix odd length keyword value
Odd length ASCII values was not taken to update keyword value for write Keyword command, as keyword length check was present in the wrong place. This commit fixes the above issue, utils:: convertToBinary is updated to fix this issue. Output: ''' Issue: odd length values not taking root@p10bmc:/tmp# ./vpd-tool -O /system/chassis/motherboard -R VSYS -K WN -V "A" -w Write keyword's value for path: /system/chassis/motherboard, Record: VSYS, Keyword: WN is failed. Exception: Write option accepts 2 digit hex numbers. (Ex. 0x1 should be given as 0x01). With the fix: root@p10bmc:/tmp# ./vpd-tool_oddLength -O /system/chassis/motherboard -R VSYS -K WN -V "A" -w Data updated successfully root@p10bmc:/tmp# vpd-tool -O /system/chassis/motherboard -R VSYS -K WN -r { "/system/chassis/motherboard": { "WN": "A " } } ''' Signed-off-by: Anupama B R <[email protected]>
1 parent c4c1359 commit ed2551d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

vpd-tool/include/tool_utils.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,17 +312,17 @@ inline types::BinaryVector convertToBinary(const std::string& i_value)
312312
"Provide a valid hexadecimal input. (Ex. 0x30313233)");
313313
}
314314

315-
if (i_value.length() % 2 != 0)
316-
{
317-
throw std::runtime_error(
318-
"Write option accepts 2 digit hex numbers. (Ex. 0x1 "
319-
"should be given as 0x01).");
320-
}
321-
322315
std::vector<uint8_t> l_binaryValue{};
323316

324317
if (i_value.substr(0, 2).compare("0x") == constants::STR_CMP_SUCCESS)
325318
{
319+
if (i_value.length() % 2 != 0)
320+
{
321+
throw std::runtime_error(
322+
"Write option accepts 2 digit hex numbers. (Ex. 0x1 "
323+
"should be given as 0x01).");
324+
}
325+
326326
auto l_value = i_value.substr(2);
327327

328328
if (l_value.empty())

0 commit comments

Comments
 (0)