iwlwifi: dbg_ini: Split memcpy() to avoid multi-field write

To avoid a run-time false positive in the stricter FORTIFY_SOURCE
memcpy() checks, split the memcpy() into the struct and the data.
Additionally switch the data member to a flexible array to follow
modern language conventions.

Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20210727205855.411487-64-keescook@chromium.org
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
This commit is contained in:
Kees Cook 2021-07-27 13:58:54 -07:00 committed by Luca Coelho
parent 583d18336a
commit cb0a1fb7fd
2 changed files with 3 additions and 2 deletions

View File

@ -119,7 +119,7 @@ enum iwl_ucode_tlv_type {
struct iwl_ucode_tlv {
__le32 type; /* see above */
__le32 length; /* not including type/length fields */
u8 data[0];
u8 data[];
};
#define IWL_TLV_UCODE_MAGIC 0x0a4c5749

View File

@ -74,7 +74,8 @@ static int iwl_dbg_tlv_add(const struct iwl_ucode_tlv *tlv,
if (!node)
return -ENOMEM;
memcpy(&node->tlv, tlv, sizeof(node->tlv) + len);
memcpy(&node->tlv, tlv, sizeof(node->tlv));
memcpy(node->tlv.data, tlv->data, len);
list_add_tail(&node->list, list);
return 0;