All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrei Borzenkov <arvidjaar@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: [PATCH 1/2] misc: fix invalid character recongition in strto*l
Date: Thu, 28 Apr 2016 21:01:28 +0300	[thread overview]
Message-ID: <57224FF8.1010203@gmail.com> (raw)
In-Reply-To: <0EB0A511-382A-4B85-8F09-1163009CA653@fb.com>

28.04.2016 03:53, Aaron Miller пишет:
> Would previously allow digits larger than the base and didn't check that
> subtracting the difference from 0-9 to lowercase letters for characters
> larger than 9 didn't result in a value lower than 9, which allowed the
> parses: ` = 9, _ = 8, ^ = 7, ] = 6, \ = 5, and [ = 4

Does it cause any real problem (i.e. is it 2.02 material)?

> ---
> 
> Need to move the out-of-base check to *after* the outside [0-9] handling
> or this breaks.
> 
>  grub-core/kern/misc.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
> index 906d2c2..3653d4d 100644
> --- a/grub-core/kern/misc.c
> +++ b/grub-core/kern/misc.c
> @@ -394,9 +394,11 @@ grub_strtoull (const char *str, char **end, int base)
>        if (digit > 9)
>      {
>        digit += '0' - 'a' + 10;
> -      if (digit >= (unsigned long) base)
> +      if (digit >= (unsigned long) base || digit <= 9)

base comparison becomes redundant here. And this needs comment
explaining digit <= 9 comparison for future reference.

>          break;
>      }
> +      if (digit >= (unsigned long) base)
> +    break;
> 
>        found = 1;
> 



  reply	other threads:[~2016-04-28 18:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-27 21:54 [PATCH 1/2] misc: fix invalid character recongition in strto*l Aaron Miller
2016-04-28  0:53 ` Aaron Miller
2016-04-28 18:01   ` Andrei Borzenkov [this message]
2016-04-29 19:12     ` Aaron Miller
2016-04-29 19:19       ` Aaron Miller
  -- strict thread matches above, loose matches on Subject: below --
2016-04-27 20:42 Aaron Miller

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=57224FF8.1010203@gmail.com \
    --to=arvidjaar@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.