From 248e35036fa2aa160a7b387cfb6209f2fe56837b Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Mon, 24 Jul 2017 14:15:42 +0200 Subject: [PATCH] Do not fail if wipe size is smaller than block size. With big page size and image in file this can actually happen. The command works in this situation but the code will be quite ineffective (due to blockwise handling). --- lib/utils_wipe.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/utils_wipe.c b/lib/utils_wipe.c index f701503f..102ea931 100644 --- a/lib/utils_wipe.c +++ b/lib/utils_wipe.c @@ -147,9 +147,11 @@ int crypt_wipe_device(struct crypt_device *cd, /* Note: LUKS1 calls it with wipe_block not aligned to multiple of bsize */ bsize = device_block_size(device); alignment = device_alignment(device); - if (!bsize || !alignment || (wipe_block_size < bsize)) + if (!bsize || !alignment || !wipe_block_size) return -EINVAL; + /* FIXME: if wipe_block_size < bsize, then a wipe is highly ineffective */ + /* Everything must be aligned to SECTOR_SIZE */ if ((offset % SECTOR_SIZE) || (length % SECTOR_SIZE) || (wipe_block_size % SECTOR_SIZE)) return -EINVAL;