dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

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

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