Received: from list by lists.gnu.org with archive (Exim 4.71) id 1bUpmO-0003uC-Ii for mharc-grub-devel@gnu.org; Wed, 03 Aug 2016 02:35:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58425) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUpmL-0003qY-0s for grub-devel@gnu.org; Wed, 03 Aug 2016 02:35:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bUpmJ-0007To-30 for grub-devel@gnu.org; Wed, 03 Aug 2016 02:35:43 -0400 Received: from smtp.nue.novell.com ([195.135.221.5]:59101) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUpmI-0007Tc-JB for grub-devel@gnu.org; Wed, 03 Aug 2016 02:35:42 -0400 Received: from nwb-ext-pat.microfocus.com ([10.120.13.103]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Wed, 03 Aug 2016 08:35:41 +0200 Received: from linux-9gqx.suse.de (nwb-a10-snat.microfocus.com [10.120.13.201]) by nwb-ext-pat.microfocus.com with ESMTP (NOT encrypted); Wed, 03 Aug 2016 07:35:09 +0100 From: Michael Chang To: Grub devel Cc: Ken Lin , Michael Chang Subject: [PATCH 1/8] misc: fix invalid character recongition in strto*l Date: Wed, 3 Aug 2016 14:34:41 +0800 Message-Id: <1470206088-16151-2-git-send-email-mchang@suse.com> X-Mailer: git-send-email 2.6.6 In-Reply-To: <1470206088-16151-1-git-send-email-mchang@suse.com> References: <1470206088-16151-1-git-send-email-mchang@suse.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.135.221.5 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Aug 2016 06:35:46 -0000 From: Aaron Miller 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