mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-05 16:00:05 +01:00
Fix a bug in LUKS2 header wipe function with keyslots area.
When formating LUKS2 device with no keyslots area (it's valid LUKS2 header) there's a bug in wipe routine that is supposed to wipe LUKS2 keyslots area. When the keyslots area size is of zero length it causes wipe function to erase whole data device starting at defined data offset.
This commit is contained in:
@@ -363,6 +363,14 @@ int LUKS2_wipe_header_areas(struct crypt_device *cd,
|
||||
offset = get_min_offset(hdr);
|
||||
length = LUKS2_keyslots_size(hdr);
|
||||
|
||||
/*
|
||||
* Skip keyslots area wipe in case it is not defined.
|
||||
* Otherwise we would wipe whole data device (length == 0)
|
||||
* starting at offset get_min_offset(hdr).
|
||||
*/
|
||||
if (!length)
|
||||
return 0;
|
||||
|
||||
log_dbg(cd, "Wiping keyslots area (0x%06" PRIx64 " - 0x%06" PRIx64") with random data.",
|
||||
offset, length + offset);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user