crypto: ccp - Silence strncpy warning
authorHerbert Xu <herbert@gondor.apana.org.au>
Thu, 9 Jul 2020 12:44:04 +0000 (22:44 +1000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 16 Jul 2020 11:49:06 +0000 (21:49 +1000)
This patch kills an strncpy by using strscpy instead.  The name
would be silently truncated if it is too long.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Acked-by: John Allen <john.allen@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/ccp/ccp-crypto-sha.c

index b0cc2bd..2bc2973 100644 (file)
@@ -19,6 +19,7 @@
 #include <crypto/internal/hash.h>
 #include <crypto/sha.h>
 #include <crypto/scatterwalk.h>
+#include <linux/string.h>
 
 #include "ccp-crypto.h"
 
@@ -424,7 +425,7 @@ static int ccp_register_hmac_alg(struct list_head *head,
        *ccp_alg = *base_alg;
        INIT_LIST_HEAD(&ccp_alg->entry);
 
-       strncpy(ccp_alg->child_alg, def->name, CRYPTO_MAX_ALG_NAME);
+       strscpy(ccp_alg->child_alg, def->name, CRYPTO_MAX_ALG_NAME);
 
        alg = &ccp_alg->alg;
        alg->setkey = ccp_sha_setkey;