grub-devel
[Top][All Lists]
Advanced

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

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


From: Vladimir 'phcoder' Serbinenko
Subject: Re: [PATCH 1/8] misc: fix invalid character recongition in strto*l
Date: Wed, 10 Aug 2016 15:51:53 +0000

Fixed, thank you for reporting. I also added a unit test for this. I didn't use your solution and instead option for a more readable one

Le Wed, Aug 3, 2016 à 8:36 AM, Michael Chang <address@hidden> a écrit :
From: Aaron Miller <address@hidden>

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 | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
index d1a54df..3a14d67 100644
--- a/grub-core/kern/misc.c
+++ b/grub-core/kern/misc.c
@@ -394,9 +394,13 @@ grub_strtoull (const char *str, char **end, int base)
       if (digit > 9)
        {
          digit += '0' - 'a' + 10;
-         if (digit >= (unsigned long) base)
+         /* digit <= 9 check is needed to keep chars larger than
+            '9' but less than 'a' from being read as numbers */
+         if (digit >= (unsigned long) base || digit <= 9)
            break;
        }
+      if (digit >= (unsigned long) base)
+       break;

       found = 1;

--
2.6.6


_______________________________________________
Grub-devel mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/grub-devel

reply via email to

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