staging: ks7010: use strscpy() to instead of strncpy()

The implementation of strscpy() is more robust and safer.
That's now the recommended way to copy NUL-terminated strings.

Signed-off-by: Xu Panda <xu.panda@zte.com.cn>
Signed-off-by: Yang Yang <yang.yang29@zte.com>
Reviewed-by: Dan Carpenter <error27@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/202212261903245548969@zte.com.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Xu Panda 2022-12-26 19:03:24 +08:00 committed by Greg Kroah-Hartman
parent 471213a377
commit 7097dc4e5b

View File

@ -382,8 +382,7 @@ static int ks_wlan_get_nick(struct net_device *dev,
return -EPERM;
/* for SLEEP MODE */
strncpy(extra, priv->nick, 16);
extra[16] = '\0';
strscpy(extra, priv->nick, 17);
dwrq->data.length = strlen(extra) + 1;
return 0;