bios_table: Relax pldm_bios_table_string_entry_decode_string_check()
Allow the string decoded by
pldm_bios_table_string_entry_decode_string_check() to be truncated, as
per the unchecked pldm_bios_table_string_entry_decode_string(). With
this change pldm_bios_table_string_entry_decode_string_check() provides
assert() safety but is otherwise equivalent.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: Ia872f1496c642efbb34ee3ae29455f4eaf574082
diff --git a/tests/libpldm_bios_table_test.cpp b/tests/libpldm_bios_table_test.cpp
index 4cefa30..c677b99 100644
--- a/tests/libpldm_bios_table_test.cpp
+++ b/tests/libpldm_bios_table_test.cpp
@@ -1006,9 +1006,10 @@
EXPECT_EQ(rc, PLDM_SUCCESS);
EXPECT_EQ(std::strcmp("Allowed", buffer.data()), 0);
- rc = pldm_bios_table_string_entry_decode_string_check(entry, buffer.data(),
- buffer.size() - 1);
- EXPECT_EQ(rc, PLDM_ERROR_INVALID_LENGTH);
+ /* Ensure equivalence with the unchecked API */
+ rc = pldm_bios_table_string_entry_decode_string_check(
+ entry, buffer.data(), 2 + 1 /* sizeof '\0' */);
+ EXPECT_EQ(rc, std::strcmp("Al", buffer.data()));
}
TEST(StringTable, IteratorTest)