wlcore: Fix buffer overrun by snprintf due to incorrect buffer size
authorColin Ian King <colin.king@canonical.com>
Mon, 19 Apr 2021 14:14:05 +0000 (15:14 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 May 2021 08:50:15 +0000 (10:50 +0200)
commit73a1ed29dfdd2fe21e7f9eceba0a10001bf0500e
treeb109f414fe83b8d841a7fbcdc38c13d324a20480
parent076495110d0530f6b6aa13bd5f771655b3cbf612
wlcore: Fix buffer overrun by snprintf due to incorrect buffer size

[ Upstream commit a9a4c080deb33f44e08afe35f4ca4bb9ece89f4e ]

The size of the buffer than can be written to is currently incorrect, it is
always the size of the entire buffer even though the snprintf is writing
as position pos into the buffer. Fix this by setting the buffer size to be
the number of bytes left in the buffer, namely sizeof(buf) - pos.

Addresses-Coverity: ("Out-of-bounds access")
Fixes: 7b0e2c4f6be3 ("wlcore: fix overlapping snprintf arguments in debugfs")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20210419141405.180582-1-colin.king@canonical.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/ti/wlcore/debugfs.h