grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[CRYPTO-LUKS v1 03/19] cryptodisk: Incorrect calculation of start sector


From: Glenn Washburn
Subject: [CRYPTO-LUKS v1 03/19] cryptodisk: Incorrect calculation of start sector for grub_disk_read in grub_cryptodisk_read.
Date: Fri, 31 Jul 2020 07:01:44 -0500

Here dev is a grub_cryptodisk_t and dev->offset is offset in sectors of size
native to the cryptodisk device. The sector is correctly transformed into
native grub sector size, but then added to dev->offset which is not
transformed. It would be nice if the type system would help us with this.

Signed-off-by: Glenn Washburn <development@efficientek.com>
---
 grub-core/disk/cryptodisk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c
index d8f66e9ef..2791a4870 100644
--- a/grub-core/disk/cryptodisk.c
+++ b/grub-core/disk/cryptodisk.c
@@ -757,8 +757,8 @@ grub_cryptodisk_read (grub_disk_t disk, grub_disk_addr_t 
sector,
                size, sector, dev->offset);
 
   err = grub_disk_read (dev->source_disk,
-                       (sector << (disk->log_sector_size
-                                  - GRUB_DISK_SECTOR_BITS)) + dev->offset, 0,
+                       ((sector + dev->offset) << (disk->log_sector_size
+                                                  - GRUB_DISK_SECTOR_BITS)), 0,
                        size << disk->log_sector_size, buf);
   if (err)
     {
-- 
2.25.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]