Skip to content

Commit 6707ba0

Browse files
arndbKalle Valo
authored andcommitted
ath10k: avoid possible string overflow
The way that 'strncat' is used here raised a warning in gcc-8: drivers/net/wireless/ath/ath10k/wmi.c: In function 'ath10k_wmi_tpc_stats_final_disp_tables': drivers/net/wireless/ath/ath10k/wmi.c:4649:4: error: 'strncat' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation] Effectively, this is simply a strcat() but the use of strncat() suggests some form of overflow check. Regardless of whether this might actually overflow, using strlcat() instead of strncat() avoids the warning and makes the code more robust. Fixes: bc64d05 ("ath10k: debugfs support to get final TPC stats for 10.4 variants") Signed-off-by: Arnd Bergmann <[email protected]> Signed-off-by: Kalle Valo <[email protected]>
1 parent a72c926 commit 6707ba0

File tree

1 file changed

+2
-2
lines changed
  • drivers/net/wireless/ath/ath10k

1 file changed

+2
-2
lines changed

drivers/net/wireless/ath/ath10k/wmi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4357,7 +4357,7 @@ static void ath10k_tpc_config_disp_tables(struct ath10k *ar,
43574357
rate_code[i],
43584358
type);
43594359
snprintf(buff, sizeof(buff), "%8d ", tpc[j]);
4360-
strncat(tpc_value, buff, strlen(buff));
4360+
strlcat(tpc_value, buff, sizeof(tpc_value));
43614361
}
43624362
tpc_stats->tpc_table[type].pream_idx[i] = pream_idx;
43634363
tpc_stats->tpc_table[type].rate_code[i] = rate_code[i];
@@ -4694,7 +4694,7 @@ ath10k_wmi_tpc_stats_final_disp_tables(struct ath10k *ar,
46944694
rate_code[i],
46954695
type, pream_idx);
46964696
snprintf(buff, sizeof(buff), "%8d ", tpc[j]);
4697-
strncat(tpc_value, buff, strlen(buff));
4697+
strlcat(tpc_value, buff, sizeof(tpc_value));
46984698
}
46994699
tpc_stats->tpc_table_final[type].pream_idx[i] = pream_idx;
47004700
tpc_stats->tpc_table_final[type].rate_code[i] = rate_code[i];

0 commit comments

Comments
 (0)