All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] misc: fix invalid character recongition in strto*l
@ 2016-04-27 21:54 Aaron Miller
  2016-04-28  0:53 ` Aaron Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Aaron Miller @ 2016-04-27 21:54 UTC (permalink / raw)
  To: grub-devel

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
---

Missed the >= vs < in the previously sent patch (I caught this, but then 
still mailed the broken patch)

  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..1c0c913 100644
--- a/grub-core/kern/misc.c
+++ b/grub-core/kern/misc.c
@@ -391,10 +391,12 @@ grub_strtoull (const char *str, char **end, int 
base)
        unsigned long digit;

        digit = grub_tolower (*str) - '0';
+      if (digit >= (unsigned long) base)
+	break;
        if (digit > 9)
  	{
  	  digit += '0' - 'a' + 10;
-	  if (digit >= (unsigned long) base)
+	  if (digit >= (unsigned long) base || digit <= 9)
  	    break;
  	}

-- 
2.8.0.rc2


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [PATCH 1/2] misc: fix invalid character recongition in strto*l
@ 2016-04-27 20:42 Aaron Miller
  0 siblings, 0 replies; 6+ messages in thread
From: Aaron Miller @ 2016-04-27 20:42 UTC (permalink / raw)
  To: grub-devel

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
---
 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..85ff109 100644
--- a/grub-core/kern/misc.c
+++ b/grub-core/kern/misc.c
@@ -391,10 +391,12 @@ grub_strtoull (const char *str, char **end, int base)
       unsigned long digit;

       digit = grub_tolower (*str) - '0';
+      if (digit < (unsigned long) base)
+	break;
       if (digit > 9)
 	{
 	  digit += '0' - 'a' + 10;
-	  if (digit >= (unsigned long) base)
+	  if (digit >= (unsigned long) base || digit <= 9)
 	    break;
 	}

-- 
2.8.0.rc2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-04-29 19:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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.