Fix offset bug in LUKS2 encryption code.

The code did not account for data offset when
set via --offset when creating new header in-before
LUKS2 encryption took place.
This commit is contained in:
Ondrej Kozina
2021-09-14 13:32:26 +02:00
parent ce704859b8
commit 1569558503
2 changed files with 13 additions and 1 deletions

View File

@@ -2249,7 +2249,11 @@ static int reencrypt_make_backup_segments(struct crypt_device *cd,
r = LUKS2_get_data_size(hdr, &tmp, NULL);
if (r)
goto err;
jobj_segment_old = json_segment_create_linear(0, tmp ? &tmp : NULL, 0);
if (params->flags & CRYPT_REENCRYPT_MOVE_FIRST_SEGMENT)
jobj_segment_old = json_segment_create_linear(0, tmp ? &tmp : NULL, 0);
else
jobj_segment_old = json_segment_create_linear(data_offset, tmp ? &tmp : NULL, 0);
}
if (!jobj_segment_old) {