]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
kern/fs: Fix possible integer overflow in i386-pc mode with large partitions
authorMaxim Fomin <maxim@fomin.one>
Wed, 28 Dec 2022 17:40:06 +0000 (17:40 +0000)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 10 Jan 2023 15:37:11 +0000 (16:37 +0100)
The i386-pc mode supports MBR partition scheme where maximum partition
size is 2 TiB. In case of large partitions left shift expression with
unsigned long int "length" object may cause integer overflow making
calculated partition size less than true value. This issue is fixed by
increasing the size of "length" integer type.

Signed-off-by: Maxim Fomin <maxim@fomin.one>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/kern/fs.c

index b9508296d3db417b2f1747c8e7d4492b6ba4d69c..7ad0aaf4e294a38b29dad50683694abc5fc4ae59 100644 (file)
@@ -130,7 +130,7 @@ grub_fs_probe (grub_device_t device)
 struct grub_fs_block
 {
   grub_disk_addr_t offset;
-  unsigned long length;
+  grub_disk_addr_t length;
 };
 
 static grub_err_t