mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-05 16:00:05 +01:00
verity: Check hash device size in advance
Let's check block device size required for Merkle tree and superblock. If it is a file, allocate the size in advance with fallocate. This should print better error message if hash device is too small. Fixes: #808
This commit is contained in:
@@ -302,6 +302,11 @@ static int VERITY_create_or_verify_hash(struct crypt_device *cd, bool verify,
|
||||
hash_device_offset_max - params->hash_area_offset);
|
||||
log_dbg(cd, "Using %d hash levels.", levels);
|
||||
|
||||
r = device_check_size(cd, crypt_metadata_device(cd),
|
||||
hash_device_offset_max - params->hash_area_offset, 1);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
data_file = fopen(device_path(crypt_data_device(cd)), "r");
|
||||
if (!data_file) {
|
||||
log_err(cd, _("Cannot open device %s."),
|
||||
|
||||
Reference in New Issue
Block a user