grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] trivial fixes for windows-efi branch


From: Vladimir 'phcoder' Serbinenko
Subject: Re: [PATCH] trivial fixes for windows-efi branch
Date: Sun, 15 Dec 2013 12:43:49 +0100

Sounds like you're looking at old version. I've fixed those problems and it's already merged in master. Could you have a look and say if any of those still a problem? As for merging with Linux part we could just have primitives set variable and get variable and have everything else shared

On Dec 15, 2013 9:04 AM, "Andrey Borzenkov" <address@hidden> wrote:
Background - I have pending rewrite for Linux to directly use sysfs
instead of relying on efibootmgr. This should fix long standing bug
where grub-install may delete wrong boot entry due to fuzzy matching.
So I just tried to rebase it on top of this branch. I think we could
reuse part of code that builds EFI device path; everything else is probably
too different.

Below fixes for problems I hit when testing it.

==

1. Check for errors when reading Boot* variables
2. Fix core dump when variable name was not found (it tried to compare
   null pointer)

Both are likely related to signed vs. unsigned comaprison mismatch where
negative values are treated as large positive.

3. Prefer minimal free boot number found, not highest one.
4. Fix length of file path component in EFI device path

---
 grub-core/osdep/windows/platform.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/grub-core/osdep/windows/platform.c b/grub-core/osdep/windows/platform.c
index e017796..4da0ed0 100644
--- a/grub-core/osdep/windows/platform.c
+++ b/grub-core/osdep/windows/platform.c
@@ -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; /* Should we abort on error? */
          if (current_len < (distrib16_len + 1) * sizeof (grub_uint16_t)
              + 6)
            {
@@ -273,10 +275,16 @@ 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; /* Should we abort here? */
          if (current_len == -1)
            {
-             order_num = i;
-             have_order_num = 1;
+             if (!have_order_num)
+             {
+               order_num = i;
+               have_order_num = 1;
+             }
+             continue;
            }
          if (current_len < (distrib16_len + 1) * sizeof (grub_uint16_t)
              + 6)
@@ -369,9 +377,9 @@ grub_install_register_efi (grub_device_t efidir_grub_dev,
                                   path8_len * GRUB_MAX_UTF16_PER_UTF8,
                                   (const grub_uint8_t *) efifile_path,
                                   path8_len, 0);
-  filep->path_name[path16_len + 1] = 0;
+  filep->path_name[path16_len] = 0;
   filep->header.length = sizeof (*filep) + (path16_len + 1) * sizeof (grub_uint16_t);
-  pathptr = &filep->path_name[path16_len + 2];
+  pathptr = &filep->path_name[path16_len + 1];
   endp = pathptr;
   endp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
   endp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
--
tg: (f3b8170..) u/windows-efi-fixes (depends on: origin/windows-efi)

_______________________________________________
Grub-devel mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/grub-devel

reply via email to

[Prev in Thread] Current Thread [Next in Thread]