]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
small fixes for Windows EFI install code
authorAndrey Borzenkov <arvidjaar@gmail.com>
Sun, 15 Dec 2013 18:00:15 +0000 (22:00 +0400)
committerAndrey Borzenkov <arvidjaar@gmail.com>
Sun, 15 Dec 2013 18:00:15 +0000 (22:00 +0400)
Fix potential crash caused by signed vs. unsigned comparison. Negative
length compares as very large unsigned number causing subsequent NULL access.

Make exhaustive search for all BootNNNN variables to find one matching
requested efi_distributor.

ChangeLog
grub-core/osdep/windows/platform.c

index bc6d68ba30a662d16bbdddeae83afbaed093fab9..7a102649936b5838bd0ba29196ad2997bdb304a8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-12-15  Andrey Borzenkov <arvidjaar@gmail.com>
+
+       * grub-core/osdep/windows/platform.c (grub_install_register_efi): Handle
+       unlikely errors when getting EFI variables and make exhaustive search
+       for all BootNNNN variables to find matching one.
+
 2013-12-15  Ian Campbell  <ijc@hellion.org.uk>
 
        * grub-core/kern/uboot/init.c: Fix units of uboot timer.
index b123256e5f6daa9638e110f1b0fce7163b52b3ee..3f4ad5e24e51ce5776de4ef8227c167826032916 100644 (file)
@@ -246,6 +246,8 @@ grub_install_register_efi (grub_device_t efidir_grub_dev,
          void *current = NULL;
          ssize_t current_len;
          current = get_efi_variable_bootn (i, &current_len);
+         if (current_len < 0)
+           continue; /* FIXME Should we abort on error? */
          if (current_len < (distrib16_len + 1) * sizeof (grub_uint16_t)
              + 6)
            {
@@ -275,13 +277,18 @@ grub_install_register_efi (grub_device_t efidir_grub_dev,
          void *current = NULL;
          ssize_t current_len;
          current = get_efi_variable_bootn (i, &current_len);
+         if (current_len < -1)
+           continue; /* FIXME Should we abort on error? */
          if (current_len == -1)
            {
-             order_num = i;
-             have_order_num = 1;
-             grub_util_info ("Creating new entry at Boot%04x",
-                             order_num);
-             break;
+             if (!have_order_num)
+               {
+                 order_num = i;
+                 have_order_num = 1;
+                 grub_util_info ("Creating new entry at Boot%04x",
+                                 order_num);
+               }
+             continue;
            }
          if (current_len < (distrib16_len + 1) * sizeof (grub_uint16_t)
              + 6)