Received: from list by lists.gnu.org with archive (Exim 4.71) id 1avaCt-0008Q4-AS for mharc-grub-devel@gnu.org; Wed, 27 Apr 2016 20:53:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58758) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avaCq-0008Ls-KW for grub-devel@gnu.org; Wed, 27 Apr 2016 20:53:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1avaCl-000872-Kc for grub-devel@gnu.org; Wed, 27 Apr 2016 20:53:24 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:38466) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avaCl-00086w-EN for grub-devel@gnu.org; Wed, 27 Apr 2016 20:53:19 -0400 Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.16.0.11/8.16.0.11) with SMTP id u3S0nAdV007060 for ; Wed, 27 Apr 2016 17:53:18 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=G1WdlSHBPupZVMKBUWaLgdEq9trKGo++btmtv0DhEdA=; b=LaMkJk/hwjdZkXA/RSwOcOXrx89Tr4VRMXcrJF4YTK1dnWCflKqbncbQizcm87brYki0 ZN4JxqhK/VJP1RPsGNAJQ2nbhr7BiLF1KoteuG+VG0avSnnj2jL6cS6kYkhHy9Ym0APQ LrW0a78nSLR71oGMZevroBMEh1mzjZdJ5iU= Received: from mail.thefacebook.com ([199.201.64.23]) by m0001303.ppops.net with ESMTP id 22g4qbjp10-1 (version=TLSv1 cipher=AES128-SHA bits=128 verify=NOT) for ; Wed, 27 Apr 2016 17:53:17 -0700 Received: from [192.168.64.1] (192.168.52.123) by mail.thefacebook.com (192.168.16.23) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 27 Apr 2016 17:53:16 -0700 From: Aaron Miller To: Subject: Re: [PATCH 1/2] misc: fix invalid character recongition in strto*l Date: Wed, 27 Apr 2016 17:53:16 -0700 Message-ID: <0EB0A511-382A-4B85-8F09-1163009CA653@fb.com> In-Reply-To: <63E370CE-24D3-45C8-AD09-506DFC023F35@fb.com> References: <63E370CE-24D3-45C8-AD09-506DFC023F35@fb.com> MIME-Version: 1.0 Content-Type: text/plain; format=flowed X-Mailer: MailMate (1.9.4r5234) X-Originating-IP: [192.168.52.123] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-04-27_14:, , signatures=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 67.231.153.30 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: Thu, 28 Apr 2016 00:53:25 -0000 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 --- Need to move the out-of-base check to *after* the outside [0-9] handling or this breaks. 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..3653d4d 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -394,9 +394,11 @@ grub_strtoull (const char *str, char **end, int base) if (digit > 9) { digit += '0' - 'a' + 10; - if (digit >= (unsigned long) base) + if (digit >= (unsigned long) base || digit <= 9) break; } + if (digit >= (unsigned long) base) + break; found = 1; -- 2.8.0.rc2 On 27 Apr 2016, at 14:54, Aaron Miller wrote: > 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 > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel