[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/9] strtoull: Fix behaviour on chars between '9' and 'a'.
From: |
Keng-Yu Lin |
Subject: |
[PATCH 1/9] strtoull: Fix behaviour on chars between '9' and 'a'. |
Date: |
Fri, 23 Dec 2016 16:54:04 +0800 |
From: Vladimir Serbinenko <address@hidden>
Reported by: Aaron Miller <address@hidden>
---
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
- [PATCH v2 0/9] Add UEFI HTTP Boot support for IPv4 and IPv6, Keng-Yu Lin, 2016/12/23
- [PATCH 1/9] strtoull: Fix behaviour on chars between '9' and 'a'.,
Keng-Yu Lin <=
- [PATCH 2/9] net: read bracketed ipv6 addrs and port numbers, Keng-Yu Lin, 2016/12/23
- [PATCH 6/9] grub.texi: Add net_bootp6 doument, Keng-Yu Lin, 2016/12/23
- [PATCH v2 3/9] Add default port in grub_net_app_protocol, Keng-Yu Lin, 2016/12/23
- [PATCH 5/9] efinet: UEFI IPv6 PXE support, Keng-Yu Lin, 2016/12/23
- [PATCH 4/9] bootp: New net_bootp6 command, Keng-Yu Lin, 2016/12/23
- [PATCH 8/9] efinet: Setting network from UEFI device path, Keng-Yu Lin, 2016/12/23
- [PATCH 7/9] bootp: Add processing DHCPACK packet from HTTP Boot, Keng-Yu Lin, 2016/12/23
- [PATCH 9/9] efinet: Setting DNS server from UEFI protocol, Keng-Yu Lin, 2016/12/23