]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* util/grub-setup.c (setup): Move copying of partition table as
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 11 Oct 2013 14:15:43 +0000 (16:15 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 11 Oct 2013 14:15:43 +0000 (16:15 +0200)
futher up as possible to avoid possible overwrite by floppy routines.

ChangeLog
util/grub-setup.c

index e0c6d63480fab7c9a4907b873858249f656cda92..087d256c9bdbcbb9796f600d77b2cddd12b23a31 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,9 @@
-2013-10-10  Vladimir Serbinenko  <phcoder@gmail.com>
+2013-10-11  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * util/grub-setup.c (setup): Move copying of partition table as
+       futher up as possible to avoid possible overwrite by floppy routines.
+
+2013-10-11  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/fs/fat.c: Fix handling of exfat contiguous files.
 
index e65c7ceedfc3e6351910d0051d38643267caab2a..3cbe81f135a34428b02be02ea7b76e39314e5abe 100644 (file)
@@ -396,6 +396,15 @@ setup (const char *dir,
 
     grub_partition_iterate (dest_dev->disk, identify_partmap, &ctx);
 
+    /* Copy the partition table.  */
+    if (ctx.dest_partmap ||
+        (!allow_floppy && !grub_util_biosdisk_is_floppy (dest_dev->disk)))
+      memcpy (boot_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC,
+             tmp_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC,
+             GRUB_BOOT_MACHINE_PART_END - GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC);
+
+    free (tmp_img);
+
     if (ctx.container
        && grub_strcmp (ctx.container->partmap->name, "msdos") == 0
        && ctx.dest_partmap
@@ -450,15 +459,6 @@ setup (const char *dir,
 
       }
 
-    /* Copy the partition table.  */
-    if (ctx.dest_partmap ||
-        (!allow_floppy && !grub_util_biosdisk_is_floppy (dest_dev->disk)))
-      memcpy (boot_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC,
-             tmp_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC,
-             GRUB_BOOT_MACHINE_PART_END - GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC);
-
-    free (tmp_img);
-    
     if (! ctx.dest_partmap && ! fs && !is_ldm)
       {
        grub_util_warn ("%s", _("Attempting to install GRUB to a partitionless disk or to a partition.  This is a BAD idea."));