mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-11 10:50:01 +01:00
Fail encryption initialization when data device too small.
This commit is contained in:
@@ -2299,7 +2299,10 @@ static int _reencrypt_init(struct crypt_device *cd,
|
||||
* encryption initialization (or mount)
|
||||
*/
|
||||
if (move_first_segment) {
|
||||
/* TODO: api test */
|
||||
if (dev_size < 2 * (params->data_shift << SECTOR_SHIFT)) {
|
||||
log_err(cd, _("Device %s is too small."), device_path(crypt_data_device(cd)));
|
||||
return -EINVAL;
|
||||
}
|
||||
if (params->data_shift < LUKS2_get_data_offset(hdr)) {
|
||||
log_err(cd, _("Data shift (%" PRIu64 " sectors) is less than future data offset (%" PRIu64 " sectors)."), params->data_shift, LUKS2_get_data_offset(hdr));
|
||||
return -EINVAL;
|
||||
|
||||
Reference in New Issue
Block a user