]> git.proxmox.com Git - grub2.git/commitdiff
fs: Fix block lists not being able to address to end of disk sometimes
authorGlenn Washburn <development@efficientek.com>
Mon, 23 Nov 2020 09:27:42 +0000 (03:27 -0600)
committerDaniel Kiper <daniel.kiper@oracle.com>
Sat, 12 Dec 2020 00:19:03 +0000 (01:19 +0100)
When checking if a block list goes past the end of the disk, make sure
the total size of the disk is in GRUB native sector sizes, otherwise there
will be blocks at the end of the disk inaccessible by block lists.

Signed-off-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/kern/fs.c

index fb30da9f404bac0fab2343294fb1c35f5b9318b7..c698295bcb410c466ecfd77a68e5b6fd875aca2d 100644 (file)
@@ -139,6 +139,7 @@ grub_fs_blocklist_open (grub_file_t file, const char *name)
   unsigned i;
   grub_disk_t disk = file->device->disk;
   struct grub_fs_block *blocks;
+  grub_size_t max_sectors;
 
   /* First, count the number of blocks.  */
   do
@@ -156,6 +157,7 @@ grub_fs_blocklist_open (grub_file_t file, const char *name)
     return 0;
 
   file->size = 0;
+  max_sectors = grub_disk_from_native_sector (disk, disk->total_sectors);
   p = (char *) name;
   for (i = 0; i < num; i++)
     {
@@ -181,7 +183,7 @@ grub_fs_blocklist_open (grub_file_t file, const char *name)
          goto fail;
        }
 
-      if (disk->total_sectors < blocks[i].offset + blocks[i].length)
+      if (max_sectors < blocks[i].offset + blocks[i].length)
        {
          grub_error (GRUB_ERR_BAD_FILENAME, "beyond the total sectors");
          goto fail;