From a93921c2262fe73708ede663f7002f4058f24e92 Mon Sep 17 00:00:00 2001 From: Ondrej Kozina Date: Mon, 4 Nov 2024 11:24:25 +0100 Subject: [PATCH] Avoid dereferencing NULL pointer. --- lib/setup.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/setup.c b/lib/setup.c index 5f53b79c..e5a162cb 100644 --- a/lib/setup.c +++ b/lib/setup.c @@ -5533,10 +5533,16 @@ static int _verify_key(struct crypt_device *cd, } else log_err(cd, _("Incorrect volume key specified for plain device.")); } else if (isLUKS1(cd->type)) { + if (!vk) + return -EINVAL; + r = LUKS_verify_volume_key(&cd->u.luks1.hdr, vk); if (r == -EPERM) log_err(cd, _("Volume key does not match the volume.")); } else if (isLUKS2(cd->type)) { + if (!vk) + return -EINVAL; + ri = LUKS2_reencrypt_status(&cd->u.luks2.hdr); if (ri == CRYPT_REENCRYPT_INVALID) return -EINVAL;