Skip to content

Commit 3d73909

Browse files
committed
crypto: lrw - Only add ecb if it is not already there
Only add ecb to the cipher name if it isn't already ecb. Also use memcmp instead of strncmp since these strings are all stored in an array of length CRYPTO_MAX_ALG_NAME. Fixes: 700cb3f ("crypto: lrw - Convert to skcipher") Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-lkp/[email protected] Signed-off-by: Herbert Xu <[email protected]>
1 parent 18c438b commit 3d73909

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

crypto/lrw.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ static int lrw_create(struct crypto_template *tmpl, struct rtattr **tb)
322322

323323
err = crypto_grab_skcipher(spawn, skcipher_crypto_instance(inst),
324324
cipher_name, 0, mask);
325-
if (err == -ENOENT) {
325+
if (err == -ENOENT && memcmp(cipher_name, "ecb(", 4)) {
326326
err = -ENAMETOOLONG;
327327
if (snprintf(ecb_name, CRYPTO_MAX_ALG_NAME, "ecb(%s)",
328328
cipher_name) >= CRYPTO_MAX_ALG_NAME)
@@ -356,7 +356,7 @@ static int lrw_create(struct crypto_template *tmpl, struct rtattr **tb)
356356
/* Alas we screwed up the naming so we have to mangle the
357357
* cipher name.
358358
*/
359-
if (!strncmp(cipher_name, "ecb(", 4)) {
359+
if (!memcmp(cipher_name, "ecb(", 4)) {
360360
int len;
361361

362362
len = strscpy(ecb_name, cipher_name + 4, sizeof(ecb_name));

0 commit comments

Comments
 (0)