Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Xu Panda and committed by
Greg Kroah-Hartman
7097dc4e 471213a3

+1 -2
+1 -2
drivers/staging/ks7010/ks_wlan_net.c
··· 382 382 return -EPERM; 383 383 384 384 /* for SLEEP MODE */ 385 - strncpy(extra, priv->nick, 16); 386 - extra[16] = '\0'; 385 + strscpy(extra, priv->nick, 17); 387 386 dwrq->data.length = strlen(extra) + 1; 388 387 389 388 return 0;