grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/2] misc: fix invalid character recongition in strto*l


From: Aaron Miller
Subject: [PATCH 1/2] misc: fix invalid character recongition in strto*l
Date: Wed, 27 Apr 2016 14:54:46 -0700

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]