ath10k: avoid possible string overflow 79/221279/1
authorArnd Bergmann <arnd@arndb.de>
Wed, 28 Mar 2018 22:06:10 +0000 (00:06 +0200)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Mon, 30 Dec 2019 10:52:10 +0000 (19:52 +0900)
commitda0a9eb6165017ebe95499cf3d96be6be16066cb
tree967dcf9e53863761f780e2ec5b9b083a55f2c53b
parent0d67e5e24aced6ce734368aeb6e9a18d133ea44f
ath10k: avoid possible string overflow

commit 6707ba0105a2d350710bc0a537a98f49eb4b895d upstream.

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: bc64d05220f3 ("ath10k: debugfs support to get final TPC stats for 10.4 variants")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[sw0312.kim: cherry-pick from stable linux-4.14.y commit 0cc17a7a3203 for gcc 9 build]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: I9e104bff8046c7ffa7f50b047dc4cd2e9fdb83e6
drivers/net/wireless/ath/ath10k/wmi.c