From ae8247fe6aa70a2c8609c079de7eb2497e553562 Mon Sep 17 00:00:00 2001 From: Ondrej Kozina Date: Thu, 2 Aug 2018 14:57:59 +0200 Subject: [PATCH] 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. --- lib/luks2/luks2_json_format.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/luks2/luks2_json_format.c b/lib/luks2/luks2_json_format.c index d9a5e0ad..a0b72ab5 100644 --- a/lib/luks2/luks2_json_format.c +++ b/lib/luks2/luks2_json_format.c @@ -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);