wifi: hostap: fix stringop-truncations GCC warning
authorKalle Valo <kvalo@kernel.org>
Tue, 13 Jun 2023 14:09:17 +0000 (17:09 +0300)
committerKalle Valo <kvalo@kernel.org>
Fri, 16 Jun 2023 09:24:16 +0000 (12:24 +0300)
With GCC 13.1 and W=1 hostap has a warning:

drivers/net/wireless/intersil/hostap/hostap_ioctl.c:3633:17: warning: 'strncpy' specified bound 16 equals destination size [-Wstringop-truncation]

fortify-string.h recommends not to use strncpy() so use strscpy() which fixes
the warning. Also now it's guarenteed that the string is NUL-terminated.

Compile tested only.

Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230613140918.389690-4-kvalo@kernel.org
drivers/net/wireless/intersil/hostap/hostap_ioctl.c

index 26287b129d186560e1964ade74a1c8b3aeb6d588..b4adfc190ae877fc54cd89bb6fb26a13fca0768b 100644 (file)
@@ -3630,7 +3630,7 @@ static int prism2_ioctl_get_encryption(local_info_t *local,
                param->u.crypt.key_len = 0;
                param->u.crypt.idx = 0xff;
        } else {
-               strncpy(param->u.crypt.alg, (*crypt)->ops->name,
+               strscpy(param->u.crypt.alg, (*crypt)->ops->name,
                        HOSTAP_CRYPT_ALG_NAME_LEN);
                param->u.crypt.key_len = 0;