Fix crypto backend to properly handle ECB mode.

Despite it should be never used, it should still work :)

Bug introduced in version 2.3.2.
This commit is contained in:
Milan Broz
2020-07-21 14:14:54 +02:00
parent b2c1ec2f83
commit 0cd7cac03f
2 changed files with 10 additions and 1 deletions

View File

@@ -64,7 +64,7 @@ static int crypt_sector_iv_init(struct crypt_sector_iv *ctx,
memset(ctx, 0, sizeof(*ctx));
ctx->iv_size = crypt_cipher_ivsize(cipher_name, mode_name);
if (ctx->iv_size < 8)
if (ctx->iv_size < 0 || (strcmp(mode_name, "ecb") && ctx->iv_size < 8))
return -ENOENT;
if (!strcmp(cipher_name, "cipher_null") ||