Skip to content

Commit

Permalink
mwifiex: Ensure the version string from the firmware is 0-terminated
Browse files Browse the repository at this point in the history
We assume at a few places that priv->version_str is 0-terminated, but
right now we trust the firmware that this is the case with the version
string we get from it.

Let's rather ensure this ourselves and replace the last character with
'\0'.

Signed-off-by: Jonas Dreßler <verdre@v0yd.nl>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20211103201800.13531-4-verdre@v0yd.nl
  • Loading branch information
Jonas Dreßler authored and Kalle Valo committed Nov 26, 2021
1 parent 939b571 commit deb573f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,9 @@ static int mwifiex_ret_ver_ext(struct mwifiex_private *priv,
MWIFIEX_VERSION_STR_LENGTH);
memcpy(priv->version_str, ver_ext->version_str,
MWIFIEX_VERSION_STR_LENGTH);

/* Ensure the version string from the firmware is 0-terminated */
priv->version_str[MWIFIEX_VERSION_STR_LENGTH - 1] = '\0';
}
return 0;
}
Expand Down

0 comments on commit deb573f

Please sign in to comment.