From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1cKLcZ-0000eD-4m for mharc-grub-devel@gnu.org; Fri, 23 Dec 2016 03:54:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47153) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cKLcX-0000e1-03 for grub-devel@gnu.org; Fri, 23 Dec 2016 03:54:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cKLcT-0005Q3-TE for grub-devel@gnu.org; Fri, 23 Dec 2016 03:54:33 -0500 Received: from g2t2352.austin.hpe.com ([15.233.44.25]:44533) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cKLcT-0005Pu-O7 for grub-devel@gnu.org; Fri, 23 Dec 2016 03:54:29 -0500 Received: from g2t2360.austin.hpecorp.net (g2t2360.austin.hpecorp.net [16.196.225.135]) by g2t2352.austin.hpe.com (Postfix) with ESMTP id 658AD59; Fri, 23 Dec 2016 08:54:28 +0000 (UTC) Received: from hpe.com (hpe.asiapacific.hpqcorp.net [16.159.110.186]) by g2t2360.austin.hpecorp.net (Postfix) with ESMTP id D37E33B; Fri, 23 Dec 2016 08:54:27 +0000 (UTC) From: Keng-Yu Lin To: grub-devel@gnu.org Cc: mchang@suse.com, ken.lin@hpe.com, ljk@hpe.com, michael.ruan@hpe.com, clayc@hpe.com, kengyu@hpe.com, Vladimir Serbinenko Subject: [PATCH 1/9] strtoull: Fix behaviour on chars between '9' and 'a'. Date: Fri, 23 Dec 2016 16:54:04 +0800 Message-Id: <1482483252-8710-2-git-send-email-kengyu@hpe.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1482483252-8710-1-git-send-email-kengyu@hpe.com> References: <1482483252-8710-1-git-send-email-kengyu@hpe.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 15.233.44.25 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: Fri, 23 Dec 2016 08:54:34 -0000 From: Vladimir Serbinenko Reported by: Aaron Miller --- grub-core/Makefile.core.def | 5 +++++ grub-core/kern/misc.c | 13 +++++++------ grub-core/tests/lib/functional_test.c | 13 +++++++++++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 2dfa22a..8dcd0e5 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1962,6 +1962,11 @@ module = { }; module = { + name = strtoull_test; + common = tests/strtoull_test.c; +}; + +module = { name = setjmp_test; common = tests/setjmp_test.c; }; diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index d1a54df..3b633d5 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -391,12 +391,13 @@ grub_strtoull (const char *str, char **end, int base) unsigned long digit; digit = grub_tolower (*str) - '0'; - if (digit > 9) - { - digit += '0' - 'a' + 10; - if (digit >= (unsigned long) base) - break; - } + if (digit >= 'a' - '0') + digit += '0' - 'a' + 10; + else if (digit > 9) + break; + + if (digit >= (unsigned long) base) + break; found = 1; diff --git a/grub-core/tests/lib/functional_test.c b/grub-core/tests/lib/functional_test.c index d4822a1..96781fb 100644 --- a/grub-core/tests/lib/functional_test.c +++ b/grub-core/tests/lib/functional_test.c @@ -26,14 +26,23 @@ GRUB_MOD_LICENSE ("GPLv3+"); static grub_err_t grub_functional_test (grub_extcmd_context_t ctxt __attribute__ ((unused)), - int argc __attribute__ ((unused)), - char **args __attribute__ ((unused))) + int argc, + char **args) { grub_test_t test; int ok = 1; + int i; FOR_LIST_ELEMENTS (test, grub_test_list) { + if (argc != 0) + { + for (i = 0; i < argc; i++) + if (grub_strcmp(args[i], test->name) == 0) + break; + if (i == argc) + continue; + } grub_errno = 0; ok = ok && !grub_test_run (test); grub_errno = 0; -- 2.7.4