]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
osdep/linux: Convert partition start to disk sector length
authorMihai Moldovan <ionic@ionic.de>
Thu, 6 Sep 2018 14:16:39 +0000 (16:16 +0200)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 27 Sep 2018 12:53:32 +0000 (14:53 +0200)
When reading data off a disk, sector values are based on the disk sector
length.

Within grub_util_fd_open_device(), the start of the partition was taken
directly from grub's partition information structure, which uses the
internal sector length (currently 512b), but never transformed to the
disk's sector length.

Subsequent calculations were all wrong for devices that have a diverging
sector length and the functions eventually skipped to the wrong stream
location, reading invalid data.

Signed-off-by: Mihai Moldovan <ionic@ionic.de>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/osdep/linux/hostdisk.c

index 06179fca72587d23b5c4d6cfc9f2fe58b1aa5b72..8b92f8528f98758a3a07c95701cfccf985b488f4 100644 (file)
@@ -374,7 +374,8 @@ grub_util_fd_open_device (const grub_disk_t disk, grub_disk_addr_t sector, int f
     char dev[PATH_MAX];
     grub_disk_addr_t part_start = 0;
 
-    part_start = grub_partition_get_start (disk->partition);
+    part_start = grub_partition_get_start (disk->partition)
+                 >> (disk->log_sector_size - GRUB_DISK_SECTOR_BITS);
 
     strncpy (dev, grub_util_biosdisk_get_osdev (disk), sizeof (dev) - 1);
     dev[sizeof(dev) - 1] = '\0';