forked from pool/grub2
Dirk Mueller
31d76fc0f5
- Fix overflow in sector count calculation (bsc#1105163) * grub2-msdos-fix-overflow.patch OBS-URL: https://build.opensuse.org/request/show/631907 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=312
47 lines
1.8 KiB
Diff
47 lines
1.8 KiB
Diff
Index: grub-2.02/grub-core/partmap/msdos.c
|
|
===================================================================
|
|
--- grub-2.02.orig/grub-core/partmap/msdos.c
|
|
+++ grub-2.02/grub-core/partmap/msdos.c
|
|
@@ -175,9 +175,9 @@ grub_partition_msdos_iterate (grub_disk_
|
|
e = mbr.entries + p.index;
|
|
|
|
p.start = p.offset
|
|
- + (grub_le_to_cpu32 (e->start)
|
|
+ + ((grub_disk_addr_t)grub_le_to_cpu32 (e->start)
|
|
<< (disk->log_sector_size - GRUB_DISK_SECTOR_BITS)) - delta;
|
|
- p.len = grub_le_to_cpu32 (e->length)
|
|
+ p.len = (grub_uint64_t)grub_le_to_cpu32 (e->length)
|
|
<< (disk->log_sector_size - GRUB_DISK_SECTOR_BITS);
|
|
p.msdostype = e->type;
|
|
|
|
@@ -217,7 +217,7 @@ grub_partition_msdos_iterate (grub_disk_
|
|
if (grub_msdos_partition_is_extended (e->type))
|
|
{
|
|
p.offset = ext_offset
|
|
- + (grub_le_to_cpu32 (e->start)
|
|
+ + ((grub_disk_addr_t)grub_le_to_cpu32 (e->start)
|
|
<< (disk->log_sector_size - GRUB_DISK_SECTOR_BITS));
|
|
if (! ext_offset)
|
|
ext_offset = p.offset;
|
|
@@ -301,9 +301,9 @@ pc_partition_map_embed (struct grub_disk
|
|
|
|
if (!grub_msdos_partition_is_empty (e->type)
|
|
&& end > offset
|
|
- + (grub_le_to_cpu32 (e->start)
|
|
+ + ((grub_disk_addr_t)grub_le_to_cpu32 (e->start)
|
|
<< (disk->log_sector_size - GRUB_DISK_SECTOR_BITS)))
|
|
- end = offset + (grub_le_to_cpu32 (e->start)
|
|
+ end = offset + ((grub_disk_addr_t)grub_le_to_cpu32 (e->start)
|
|
<< (disk->log_sector_size - GRUB_DISK_SECTOR_BITS));
|
|
|
|
/* If this is a GPT partition, this MBR is just a dummy. */
|
|
@@ -319,7 +319,7 @@ pc_partition_map_embed (struct grub_disk
|
|
if (grub_msdos_partition_is_extended (e->type))
|
|
{
|
|
offset = ext_offset
|
|
- + (grub_le_to_cpu32 (e->start)
|
|
+ + ((grub_disk_addr_t)grub_le_to_cpu32 (e->start)
|
|
<< (disk->log_sector_size - GRUB_DISK_SECTOR_BITS));
|
|
if (! ext_offset)
|
|
ext_offset = offset;
|