From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1VsB1X-00076n-0W for mharc-grub-devel@gnu.org; Sun, 15 Dec 2013 07:42:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45957) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VsB1N-00076c-N9 for grub-devel@gnu.org; Sun, 15 Dec 2013 07:42:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VsB1F-0007hU-95 for grub-devel@gnu.org; Sun, 15 Dec 2013 07:42:09 -0500 Received: from mail-lb0-x22f.google.com ([2a00:1450:4010:c04::22f]:42131) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VsB1F-0007g8-1G for grub-devel@gnu.org; Sun, 15 Dec 2013 07:42:01 -0500 Received: by mail-lb0-f175.google.com with SMTP id w6so439261lbh.6 for ; Sun, 15 Dec 2013 04:42:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; bh=8IMwG/IDVgSSMoQw+MZPNL8QIw96thJziCHLCTVzFz0=; b=0OVeZulFL/haiR/RggbcwqAHpRIiK28qsTyUx5gGxFAL1+ABu4OSABsicZCr0ppGUq 59zk7tYgrzphezVwjnZ1QABZj4R6i5YY3wCNDb0r5ZbLScE8LdcHyW727dKvrXhyqrx4 FT37sgh8ZprYrbYRbveVQ/nJns1P97vtZqTgKw+F14Vcrn0oEiY3QE9FjTBX1dJZ/Olt aXRY3uLW76BeZkTC7tSlYYldGRzC9maIkPAT8uLLZXKq5JHElK+8616y5LFo9iLyzy8F /wpvFOKZJLNla8clcGeOq91doSJNVn4B+nAIuEsrVemytCY4m/ocGCoJczX/0z6yxDl9 9EBg== X-Received: by 10.152.8.131 with SMTP id r3mr135490laa.79.1387111319911; Sun, 15 Dec 2013 04:41:59 -0800 (PST) Received: from opensuse.site (ppp91-76-134-134.pppoe.mtu-net.ru. [91.76.134.134]) by mx.google.com with ESMTPSA id di11sm15784208lac.0.2013.12.15.04.41.59 for (version=SSLv3 cipher=RC4-SHA bits=128/128); Sun, 15 Dec 2013 04:41:59 -0800 (PST) Date: Sun, 15 Dec 2013 16:41:58 +0400 From: Andrey Borzenkov To: grub-devel@gnu.org Subject: Re: [PATCH] trivial fixes for windows-efi branch Message-ID: <20131215164158.697735fc@opensuse.site> In-Reply-To: References: <1387094652-14021-1-git-send-email-arvidjaar@gmail.com> X-Mailer: Claws Mail 3.9.2 (GTK+ 2.24.22; x86_64-suse-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::22f 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 12:42:18 -0000 В Sun, 15 Dec 2013 12:43:49 +0100 "Vladimir 'phcoder' Serbinenko" пишет: > 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? Yes, it fixed file path and variable not existed in exhaustive search. Still see comments below. diff --git a/grub-core/osdep/windows/platform.c b/grub-core/osdep/windows/platform.c index b123256..3f4ad5e 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; /* FIXME Should we abort on error? */ if (current_len < (distrib16_len + 1) * sizeof (grub_uint16_t) + 6) { Same potential problem with signed vs. unsigned comparison. Variable is not guaranteed to exist here and -1 is treated as very large unsigned value. @@ -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, ¤t_len); + if (current_len < -1) + continue; /* FIXME Should we abort on error? */ For completeness we should handle failures to avoid crash. 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; } You changed it to stop on first non-existing variable; but this can miss another one later with the same description. This will result in two different boot entries with the same name. I cannot test it on Windows; on Linux code appears to be fast enough. > As for merging with Linux part we could just have > primitives set variable and get variable and have everything else shared Yes, I'll get a look.