grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: [PATCH] trivial fixes for windows-efi branch
Date: Sun, 15 Dec 2013 13:51:36 +0100	[thread overview]
Message-ID: <52ADA5D8.5030309@gmail.com> (raw)
In-Reply-To: <20131215164158.697735fc@opensuse.site>

[-- Attachment #1: Type: text/plain, Size: 3072 bytes --]

On 15.12.2013 13:41, Andrey Borzenkov wrote:
> В Sun, 15 Dec 2013 12:43:49 +0100
> "Vladimir 'phcoder' Serbinenko" <phcoder@gmail.com> пишет:
> 
>> 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, &current_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.
> 
Yes, apparently mingw treats here as siged comparison and no warning is
emitted. As for the comment, the reasons for possible failure are
somewhat unclear to me, other than permission denied one. On Windows you
wouldn't get here if permission is denied (you'd stop at token
manipulation). Some kind of internal EFI failure may leave some
variables unusable while otherwise allowing algorithm to work.
> @@ -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? */
> 
> For completeness we should handle failures to avoid crash.
> 
Same.
Go ahead for those 2 hunks.
>  	  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.
> 
I'll test think hunk on my next reboot.
>>                       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.
> 
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 291 bytes --]

  reply	other threads:[~2013-12-15 12:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-15  8:04 [PATCH] trivial fixes for windows-efi branch Andrey Borzenkov
2013-12-15 11:43 ` Vladimir 'phcoder' Serbinenko
2013-12-15 12:41   ` Andrey Borzenkov
2013-12-15 12:51     ` Vladimir 'φ-coder/phcoder' Serbinenko [this message]
2013-12-15 16:43     ` Vladimir 'φ-coder/phcoder' Serbinenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52ADA5D8.5030309@gmail.com \
    --to=phcoder@gmail.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).