crypto: essiv - Replace memcpy() + NUL-termination with strscpy()
authorThorsten Blum <thorsten.blum@linux.dev>
Sun, 16 Mar 2025 21:15:04 +0000 (22:15 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 21 Mar 2025 09:39:06 +0000 (17:39 +0800)
Use strscpy() to copy the NUL-terminated string 'p' to the destination
buffer instead of using memcpy() followed by a manual NUL-termination.

No functional changes intended.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/essiv.c

index 1c00c3324058c227b650ec15d707d8b38a4efa25..ec0ec8992c2da5bf2c29a34dc8c22514894b2fec 100644 (file)
@@ -405,8 +405,7 @@ static bool parse_cipher_name(char *essiv_cipher_name, const char *cra_name)
        if (len >= CRYPTO_MAX_ALG_NAME)
                return false;
 
-       memcpy(essiv_cipher_name, p, len);
-       essiv_cipher_name[len] = '\0';
+       strscpy(essiv_cipher_name, p, len + 1);
        return true;
 }