From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Vs6gn-0008O8-NV for mharc-grub-devel@gnu.org; Sun, 15 Dec 2013 03:04:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42741) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vs6gd-0008NH-6c for grub-devel@gnu.org; Sun, 15 Dec 2013 03:04:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vs6gU-0004lr-FG for grub-devel@gnu.org; Sun, 15 Dec 2013 03:04:27 -0500 Received: from mail-la0-x22e.google.com ([2a00:1450:4010:c03::22e]:61107) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vs6gU-0004ll-70 for grub-devel@gnu.org; Sun, 15 Dec 2013 03:04:18 -0500 Received: by mail-la0-f46.google.com with SMTP id eh20so2223352lab.19 for ; Sun, 15 Dec 2013 00:04:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=2tVLqf8W/POXRDHFrJf+68iF2kwcvNx6Q3m5bJC3vXY=; b=OhRfJumk2MSGRumjhRFr0ZPUg7C2j6I7oT4Rh6yXq9USvHdq3HEGqTSxGoUJ27yN++ Llz8IbFmzI9S+MvK5BeQPYYWcnq4nLieDYowhI1Y5j/qdb+pHr3eyXOMfkxNRLQBhAfF Vjp98lHx4wc8RM7ffmq6sla4SPKmxVriTgNv+qX+qdoqEqfGikn8/kWjWS9bfxw5tExt +wtOJxiLcpzpRQUvt8/zV/LgMMZwcPjTJX6XRsOSKWP+Tl+rmTONm/NvKVjVXt9GyyNL 45eRWdI5jJF8kFzoB2Iv8+Gb75N4E85qzB6/IxdGELyyNYXaBxmuPr68xWgwOyMIl+OO MlGA== X-Received: by 10.152.1.234 with SMTP id 10mr4557445lap.19.1387094657043; Sun, 15 Dec 2013 00:04:17 -0800 (PST) Received: from localhost.localdomain (ppp91-76-134-134.pppoe.mtu-net.ru. [91.76.134.134]) by mx.google.com with ESMTPSA id ox6sm5119278lbb.6.2013.12.15.00.04.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Dec 2013 00:04:16 -0800 (PST) From: Andrey Borzenkov To: grub-devel@gnu.org Subject: [PATCH] trivial fixes for windows-efi branch Date: Sun, 15 Dec 2013 12:04:12 +0400 Message-Id: <1387094652-14021-1-git-send-email-arvidjaar@gmail.com> X-Mailer: git-send-email 1.8.4 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::22e X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Dec 2013 08:04:35 -0000 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, ¤t_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, ¤t_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)