From f5b7a576b35b25a26f47968ff726f66e08e41197 Mon Sep 17 00:00:00 2001 From: Ondrej Kozina Date: Mon, 4 Nov 2024 11:23:57 +0100 Subject: [PATCH] Do not dereference the context pointer before assert. --- lib/setup.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/setup.c b/lib/setup.c index 6c89781e..5f53b79c 100644 --- a/lib/setup.c +++ b/lib/setup.c @@ -5524,7 +5524,6 @@ static int _verify_key(struct crypt_device *cd, { int r = -EINVAL; crypt_reencrypt_info ri; - struct luks2_hdr *hdr = &cd->u.luks2.hdr; assert(cd); @@ -5538,13 +5537,13 @@ static int _verify_key(struct crypt_device *cd, if (r == -EPERM) log_err(cd, _("Volume key does not match the volume.")); } else if (isLUKS2(cd->type)) { - ri = LUKS2_reencrypt_status(hdr); + ri = LUKS2_reencrypt_status(&cd->u.luks2.hdr); if (ri == CRYPT_REENCRYPT_INVALID) return -EINVAL; if (ri > CRYPT_REENCRYPT_NONE) { - LUKS2_reencrypt_lookup_key_ids(cd, hdr, vk); - r = LUKS2_reencrypt_digest_verify(cd, hdr, vk); + LUKS2_reencrypt_lookup_key_ids(cd, &cd->u.luks2.hdr, vk); + r = LUKS2_reencrypt_digest_verify(cd, &cd->u.luks2.hdr, vk); if (r == -EPERM || r == -ENOENT || r == -EINVAL) log_err(cd, _("Reencryption volume keys do not match the volume.")); return r;