File grub2-msdos-fix-overflow.patch of Package grub2.14407

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;
openSUSE Build Service is sponsored by