Calculate keyslots area size properly with detached headers.

When LUKS2 crypt_format() is called with detached header and custom data
alignment is requested, keyslots area is miscalculated. This mistake
is correctly detected by LUKS2 validation code but it's feature
regression with regard to LUKSv1 format.
This commit is contained in:
Ondrej Kozina
2018-08-02 14:57:59 +02:00
committed by Milan Broz
parent d664565174
commit ae8247fe6a

View File

@@ -212,7 +212,7 @@ int LUKS2_generate_hdr(
/* for detached metadata device compute reasonable keyslot areas size */
// FIXME: this is coupled with FIXME above
if (detached_metadata_device)
if (detached_metadata_device && !offset)
keyslots_size = LUKS2_HDR_DEFAULT_LEN - get_min_offset(hdr);
else
keyslots_size = offset - get_min_offset(hdr);