@@ -86,7 +86,7 @@ static int wlcore_validate_fw_ver(struct wl1271 *wl)
unsigned int *min_ver = (wl->fw_type == WL12XX_FW_TYPE_MULTI) ?
wl->min_mr_fw_ver : wl->min_sr_fw_ver;
char min_fw_str[32] = "";
- int i;
+ int i, len;
/* the chip must be exactly equal */
if ((min_ver[FW_VER_CHIP] != WLCORE_FW_VER_IGNORE) &&
@@ -119,13 +119,15 @@ static int wlcore_validate_fw_ver(struct wl1271 *wl)
return 0;
fail:
+ len = 0;
for (i = 0; i < NUM_FW_VER; i++)
if (min_ver[i] == WLCORE_FW_VER_IGNORE)
- snprintf(min_fw_str, sizeof(min_fw_str),
- "%s*.", min_fw_str);
+ len += scnprintf(min_fw_str + len,
+ sizeof(min_fw_str) - len, "*.");
else
- snprintf(min_fw_str, sizeof(min_fw_str),
- "%s%u.", min_fw_str, min_ver[i]);
+ len += scnprintf(min_fw_str + len,
+ sizeof(min_fw_str) - len,
+ "%u.", min_ver[i]);
wl1271_error("Your WiFi FW version (%u.%u.%u.%u.%u) is invalid.\n"
"Please use at least FW %s\n"
Appending to a buffer like this is not guaranteed to work (passing overlapping src and dst buffers to snprintf is undefined behaviour). The standard and safe idiom is to keep track of the current string length. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> --- drivers/net/wireless/ti/wlcore/boot.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)