soc: qcom: wcnss_ctrl: Avoid string overflow
authorNiklas Cassel <niklas.cassel@linaro.org>
Wed, 29 Aug 2018 07:57:21 +0000 (09:57 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Nov 2019 17:46:37 +0000 (18:46 +0100)
commit6651ecf92f3cbe91358b5b190b39a674607b03ae
tree02d866c40954a649e4b17ebe8a72e78a56cfa985
parent4a2c4d1a0b6bdaf28391107375bc14c9fdc2109b
soc: qcom: wcnss_ctrl: Avoid string overflow

[ Upstream commit 4c96ed170d658d8826d94edec8ac93ee777981a2 ]

'chinfo.name' is used as a NUL-terminated string, but using strncpy() with
the length equal to the buffer size may result in lack of the termination:

drivers//soc/qcom/wcnss_ctrl.c: In function 'qcom_wcnss_open_channel':
drivers//soc/qcom/wcnss_ctrl.c:284:2: warning: 'strncpy' specified bound 32 equals destination size [-Wstringop-truncation]
  strncpy(chinfo.name, name, sizeof(chinfo.name));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This changes it to use the safer strscpy() instead.

Signed-off-by: Niklas Cassel <niklas.cassel@linaro.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Andy Gross <andy.gross@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/soc/qcom/wcnss_ctrl.c