bios_table: Check the attr type when set attr value

When setting an attribute, we only checked whether
the attributes's type is non-read-only, but the remote
may send a non-read-only type that does not match the
attribute.

eg, set an integer attribute:

the remote should send:
1(attr handle), 0x03(attr type,integer, non-read-only),100(integer value)

but it may send:
1(attr handle), 0x01(attr type,string, non-read-only),100(integer value)
which is wrong.

Signed-off-by: John Wang <wangzqbj@inspur.com>
Change-Id: I7db8b65f39b40624202627e2b4f94088dee0b423
diff --git a/libpldm/bios_table.c b/libpldm/bios_table.c
index 2f8d7f1..8c04f36 100644
--- a/libpldm/bios_table.c
+++ b/libpldm/bios_table.c
@@ -1059,7 +1059,7 @@
 	    src_table, src_length, PLDM_BIOS_ATTR_VAL_TABLE);
 
 	int rc = PLDM_SUCCESS;
-	const struct pldm_bios_attr_val_table_entry *tmp;
+	const struct pldm_bios_attr_val_table_entry *tmp, *to_update = entry;
 	size_t buffer_length = *dest_length, copied_length = 0, length = 0;
 	while (!pldm_bios_table_iter_is_end(iter)) {
 		tmp = pldm_bios_table_iter_attr_value_entry_value(iter);
@@ -1069,9 +1069,11 @@
 		 * it too, use current_pos directly to avoid calculating it
 		 * twice */
 		iter->current_pos += length;
-		if (tmp->attr_handle ==
-		    ((const struct pldm_bios_attr_val_table_entry *)entry)
-			->attr_handle) {
+		if (tmp->attr_handle == to_update->attr_handle) {
+			if (tmp->attr_type != to_update->attr_type) {
+				rc = PLDM_ERROR_INVALID_DATA;
+				goto out;
+			}
 			if (attribute_is_readonly(tmp->attr_type)) {
 				rc = PLDM_ERROR_INVALID_DATA;
 				goto out;