]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
crypto: octeontx2 - Replace deprecated strcpy in cpt_ucode_load_fw
authorThorsten Blum <thorsten.blum@linux.dev>
Sat, 1 Nov 2025 14:04:42 +0000 (15:04 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 6 Nov 2025 06:31:08 +0000 (14:31 +0800)
strcpy() is deprecated; use the safer strscpy() instead.

The destination buffer is only zero-initialized for the first iteration
and since strscpy() guarantees its NUL termination anyway, remove
zero-initializing 'eng_type'.

Link: https://github.com/KSPP/linux/issues/88
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c

index ebdf4efa09d4d70733671343f0bc21f2276970d2..b5cc5401f7044b155792212f36c1fa2359c7d11a 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <linux/ctype.h>
 #include <linux/firmware.h>
+#include <linux/string.h>
 #include <linux/string_choices.h>
 #include "otx2_cptpf_ucode.h"
 #include "otx2_cpt_common.h"
@@ -458,13 +459,13 @@ static int cpt_ucode_load_fw(struct pci_dev *pdev, struct fw_info_t *fw_info,
                             u16 rid)
 {
        char filename[OTX2_CPT_NAME_LENGTH];
-       char eng_type[8] = {0};
+       char eng_type[8];
        int ret, e, i;
 
        INIT_LIST_HEAD(&fw_info->ucodes);
 
        for (e = 1; e < OTX2_CPT_MAX_ENG_TYPES; e++) {
-               strcpy(eng_type, get_eng_type_str(e));
+               strscpy(eng_type, get_eng_type_str(e));
                for (i = 0; i < strlen(eng_type); i++)
                        eng_type[i] = tolower(eng_type[i]);