From 7825e0d4a638420d5968fadcb61e70cfca64b933 Mon Sep 17 00:00:00 2001 From: Ondrej Kozina Date: Thu, 18 Feb 2021 14:22:51 +0100 Subject: [PATCH] Bypass keyring activation flag if cipher is null. --- lib/libdevmapper.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/libdevmapper.c b/lib/libdevmapper.c index d3cb2442..374ada13 100644 --- a/lib/libdevmapper.c +++ b/lib/libdevmapper.c @@ -654,11 +654,13 @@ static char *get_dm_crypt_params(const struct dm_target *tgt, uint32_t flags) if (crypt_is_cipher_null(cipher_dm)) null_cipher = 1; - if (flags & CRYPT_ACTIVATE_KEYRING_KEY) { + if (null_cipher) + hexkey = crypt_safe_alloc(2); + else if (flags & CRYPT_ACTIVATE_KEYRING_KEY) { keystr_len = strlen(tgt->u.crypt.vk->key_description) + int_log10(tgt->u.crypt.vk->keylength) + 10; hexkey = crypt_safe_alloc(keystr_len); } else - hexkey = crypt_safe_alloc(null_cipher ? 2 : (tgt->u.crypt.vk->keylength * 2 + 1)); + hexkey = crypt_safe_alloc(tgt->u.crypt.vk->keylength * 2 + 1); if (!hexkey) return NULL;