mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-06 00:10:04 +01:00
lib: fix potential segfault in _keyslot_repair
The value of vk may be NULL in _keyslot_repair. It will be dereferenced in LUKS_generate_phdr. Check it to avoid segfault. Signed-off-by: Lixiaokeng <lixiaokeng@huawei.com> Signed-off-by: Linfeilong <linfeilong@huawei.com>
This commit is contained in:
@@ -386,6 +386,8 @@ static int _keyslot_repair(struct luks_phdr *phdr, struct crypt_device *ctx)
|
||||
return -EINVAL;
|
||||
|
||||
vk = crypt_alloc_volume_key(phdr->keyBytes, NULL);
|
||||
if (!vk)
|
||||
return -ENOMEM;
|
||||
|
||||
log_verbose(ctx, _("Repairing keyslots."));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user