The function grub_disk_native_sectors(source) returns the number of sectors of source in grub native (512-byte) sectors, not source sized sectors. So the conversion needs to use GRUB_DISK_SECTOR_BITS. the grub native sector size.
Signed-off-by: Glenn Washburn <developm...@efficientek.com> --- grub-core/disk/luks2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c index 8d2457557..8c1156dd0 100644 --- a/grub-core/disk/luks2.c +++ b/grub-core/disk/luks2.c @@ -631,7 +631,7 @@ luks2_recover_key (grub_disk_t source, crypt->log_sector_size = sizeof (unsigned int) * 8 - __builtin_clz ((unsigned int) segment.sector_size) - 1; if (grub_strcmp (segment.size, "dynamic") == 0) - crypt->total_sectors = (grub_disk_native_sectors (source) >> (crypt->log_sector_size - source->log_sector_size)) + crypt->total_sectors = (grub_disk_native_sectors (source) >> (crypt->log_sector_size - GRUB_DISK_SECTOR_BITS)) - crypt->offset_sectors; else crypt->total_sectors = grub_strtoull (segment.size, NULL, 10) >> crypt->log_sector_size; -- 2.27.0 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel