]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Fix definition of grub_efi_hard_drive_device_path. Take care that
authorVladimir Serbinenko <phcoder@gmail.com>
Sat, 14 Dec 2013 21:04:02 +0000 (22:04 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Sat, 14 Dec 2013 21:04:02 +0000 (22:04 +0100)
existing code would work even if by some reason bogus definition is
used by EFI implementations.

ChangeLog
grub-core/disk/efi/efidisk.c
grub-core/kern/efi/efi.c
include/grub/efi/api.h

index d8ffc725efe8f37c516444c3b0cec048ac07e114..d28ca02d20d67aeaa5a6a967e0dbaf12dcb61220 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-12-14  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Fix definition of grub_efi_hard_drive_device_path. Take care that
+       existing code would work even if by some reason bogus definition is
+       used by EFI implementations.
+
 2013-12-14  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/osdep/windows/hostdisk.c: Fix cygwin compilation.
index 68f6d9f755afbf07d6e1c490176d10b88a4f7bfe..e04203fe0b1d67d867f55bdece04f83a18967404 100644 (file)
@@ -666,20 +666,20 @@ grub_efidisk_get_device_handle (grub_disk_t disk)
        devices = make_devices ();
        FOR_CHILDREN (c, devices)
          {
-           grub_efi_hard_drive_device_path_t hd;
+           grub_efi_hard_drive_device_path_t *hd;
 
-           grub_memcpy (&hd, c->last_device_path, sizeof (hd));
+           hd = (grub_efi_hard_drive_device_path_t *) c->last_device_path;
 
            if ((GRUB_EFI_DEVICE_PATH_TYPE (c->last_device_path)
                 == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE)
                && (GRUB_EFI_DEVICE_PATH_SUBTYPE (c->last_device_path)
                    == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE)
                && (grub_partition_get_start (disk->partition) 
-                   == (hd.partition_start << (disk->log_sector_size
-                                              - GRUB_DISK_SECTOR_BITS)))
+                   == (hd->partition_start << (disk->log_sector_size
+                                               - GRUB_DISK_SECTOR_BITS)))
                && (grub_partition_get_len (disk->partition)
-                   == (hd.partition_size << (disk->log_sector_size
-                                             - GRUB_DISK_SECTOR_BITS))))
+                   == (hd->partition_size << (disk->log_sector_size
+                                              - GRUB_DISK_SECTOR_BITS))))
              {
                handle = c->handle;
                break;
@@ -745,7 +745,7 @@ get_diskname_from_path (const grub_efi_device_path_t *path,
 struct grub_efidisk_get_device_name_ctx
 {
   char *partition_name;
-  grub_efi_hard_drive_device_path_t hd;
+  grub_efi_hard_drive_device_path_t *hd;
 };
 
 /* Helper for grub_efidisk_get_device_name.
@@ -757,11 +757,11 @@ grub_efidisk_get_device_name_iter (grub_disk_t disk,
   struct grub_efidisk_get_device_name_ctx *ctx = data;
 
   if (grub_partition_get_start (part)
-      == (ctx->hd.partition_start << (disk->log_sector_size
-                                     - GRUB_DISK_SECTOR_BITS))
+      == (ctx->hd->partition_start << (disk->log_sector_size
+                                      - GRUB_DISK_SECTOR_BITS))
       && grub_partition_get_len (part)
-      == (ctx->hd.partition_size << (disk->log_sector_size
-                                    - GRUB_DISK_SECTOR_BITS)))
+      == (ctx->hd->partition_size << (disk->log_sector_size
+                                     - GRUB_DISK_SECTOR_BITS)))
     {
       ctx->partition_name = grub_partition_get_name (part);
       return 1;
@@ -831,10 +831,10 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
 
       /* Find a partition which matches the hard drive device path.  */
       ctx.partition_name = NULL;
-      grub_memcpy (&ctx.hd, ldp, sizeof (ctx.hd));
-      if (ctx.hd.partition_start == 0
-         && (ctx.hd.partition_size << (parent->log_sector_size
-                                       - GRUB_DISK_SECTOR_BITS))
+      ctx.hd = (grub_efi_hard_drive_device_path_t *) ldp;
+      if (ctx.hd->partition_start == 0
+         && (ctx.hd->partition_size << (parent->log_sector_size
+                                        - GRUB_DISK_SECTOR_BITS))
          == grub_disk_get_size (parent))
        {
          dev_name = grub_strdup (parent->name);
index 19a57d55382e9f571841131515a7e8a5c92e338c..c2a5c32ff259bb394ab473d55d8f5cdce520d102 100644 (file)
@@ -704,7 +704,7 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
                             (unsigned) hd->partition_signature[5],
                             (unsigned) hd->partition_signature[6],
                             (unsigned) hd->partition_signature[7],
-                            (unsigned) hd->mbr_type,
+                            (unsigned) hd->partmap_type,
                             (unsigned) hd->signature_type);
              }
              break;
index 623ef14f93c65101a6bec05adcd631f2f446e757..7b46259f72689f2b897bc13e4497f77cf8485ea5 100644 (file)
@@ -827,8 +827,8 @@ struct grub_efi_hard_drive_device_path
   grub_efi_uint32_t partition_number;
   grub_efi_lba_t partition_start;
   grub_efi_lba_t partition_size;
-  grub_efi_uint8_t partition_signature[8];
-  grub_efi_uint8_t mbr_type;
+  grub_efi_uint8_t partition_signature[16];
+  grub_efi_uint8_t partmap_type;
   grub_efi_uint8_t signature_type;
 } __attribute__ ((packed));
 typedef struct grub_efi_hard_drive_device_path grub_efi_hard_drive_device_path_t;