Skip to content

Commit 270b6f1

Browse files
committed
crypto: xts - 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: f1c131b ("crypto: xts - Convert to skcipher") Signed-off-by: Herbert Xu <[email protected]>
1 parent 3d73909 commit 270b6f1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

crypto/xts.c

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

364364
err = crypto_grab_skcipher(&ctx->spawn, skcipher_crypto_instance(inst),
365365
cipher_name, 0, mask);
366-
if (err == -ENOENT) {
366+
if (err == -ENOENT && memcmp(cipher_name, "ecb(", 4)) {
367367
err = -ENAMETOOLONG;
368368
if (snprintf(name, CRYPTO_MAX_ALG_NAME, "ecb(%s)",
369369
cipher_name) >= CRYPTO_MAX_ALG_NAME)
@@ -397,7 +397,7 @@ static int xts_create(struct crypto_template *tmpl, struct rtattr **tb)
397397
/* Alas we screwed up the naming so we have to mangle the
398398
* cipher name.
399399
*/
400-
if (!strncmp(cipher_name, "ecb(", 4)) {
400+
if (!memcmp(cipher_name, "ecb(", 4)) {
401401
int len;
402402

403403
len = strscpy(name, cipher_name + 4, sizeof(name));

0 commit comments

Comments
 (0)