Return -ENOENT if digest is missing.

If there is no digest associated with segment,
for example during reencryption mode encrypt initialization,
return -ENOENT in LUKS2_digest_verify_by_segment.
This commit is contained in:
Ondrej Kozina
2025-05-19 16:15:10 +02:00
parent 1a7e89c55d
commit 5a84dc87e3
2 changed files with 7 additions and 3 deletions

View File

@@ -160,7 +160,7 @@ int LUKS2_digest_verify_by_segment(struct crypt_device *cd,
int segment,
const struct volume_key *vk)
{
int r = -EINVAL;
int r;
unsigned s;
if (segment == CRYPT_ANY_SEGMENT) {
@@ -172,7 +172,11 @@ int LUKS2_digest_verify_by_segment(struct crypt_device *cd,
return -EPERM;
}
return LUKS2_digest_verify_by_digest(cd, LUKS2_digest_by_segment(hdr, segment), vk);
r = LUKS2_digest_by_segment(hdr, segment);
if (r < 0)
return r;
return LUKS2_digest_verify_by_digest(cd, r, vk);
}
/* FIXME: segment can have more digests */