crypto: core - move from strlcpy with unused retval to strscpy
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Thu, 18 Aug 2022 20:59:54 +0000 (22:59 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 26 Aug 2022 10:50:38 +0000 (18:50 +0800)
Follow the advice of the below link and prefer 'strscpy' in this
subsystem. Conversion is 1:1 because the return value is not used.
Generated by a coccinelle script.

Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/api.c
crypto/essiv.c

index ab4b5e2..64f2d36 100644 (file)
@@ -114,7 +114,7 @@ struct crypto_larval *crypto_larval_alloc(const char *name, u32 type, u32 mask)
        larval->alg.cra_priority = -1;
        larval->alg.cra_destroy = crypto_larval_destroy;
 
-       strlcpy(larval->alg.cra_name, name, CRYPTO_MAX_ALG_NAME);
+       strscpy(larval->alg.cra_name, name, CRYPTO_MAX_ALG_NAME);
        init_completion(&larval->completion);
 
        return larval;
index 8bcc5bd..e33369d 100644 (file)
@@ -543,7 +543,7 @@ static int essiv_create(struct crypto_template *tmpl, struct rtattr **tb)
        }
 
        /* record the driver name so we can instantiate this exact algo later */
-       strlcpy(ictx->shash_driver_name, hash_alg->base.cra_driver_name,
+       strscpy(ictx->shash_driver_name, hash_alg->base.cra_driver_name,
                CRYPTO_MAX_ALG_NAME);
 
        /* Instance fields */