dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0249-misc-fix-invalid-character-recongition-in-strto-l.patch

f725e3
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
f725e3
From: Aaron Miller <aaronmiller@fb.com>
f725e3
Date: Fri, 29 Jul 2016 17:41:27 +0800
f725e3
Subject: [PATCH] misc: fix invalid character recongition in strto*l
f725e3
f725e3
Would previously allow digits larger than the base and didn't check that
f725e3
subtracting the difference from 0-9 to lowercase letters for characters
f725e3
larger than 9 didn't result in a value lower than 9, which allowed the
f725e3
parses: ` = 9, _ = 8, ^ = 7, ] = 6, \ = 5, and [ = 4
f725e3
---
f725e3
 grub-core/kern/misc.c | 6 +++++-
f725e3
 1 file changed, 5 insertions(+), 1 deletion(-)
f725e3
f725e3
diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
f725e3
index 240396c55f3..d0ca2ee603b 100644
f725e3
--- a/grub-core/kern/misc.c
f725e3
+++ b/grub-core/kern/misc.c
f725e3
@@ -436,9 +436,13 @@ grub_strtoull (const char *str, char **end, int base)
f725e3
       if (digit > 9)
f725e3
 	{
f725e3
 	  digit += '0' - 'a' + 10;
f725e3
-	  if (digit >= (unsigned long) base)
f725e3
+	  /* digit <= 9 check is needed to keep chars larger than
f725e3
+	     '9' but less than 'a' from being read as numbers */
f725e3
+	  if (digit >= (unsigned long) base || digit <= 9)
f725e3
 	    break;
f725e3
 	}
f725e3
+      if (digit >= (unsigned long) base)
f725e3
+	break;
f725e3
 
f725e3
       found = 1;
f725e3