From 4dee187a7b30a8a666adf01a56cebca1f78e15f0 Mon Sep 17 00:00:00 2001 From: Daniel Axtens Date: Wed, 13 Jan 2021 22:19:01 +1100 Subject: [PATCH] kern/misc: Always set *end in grub_strtoull() Currently, if there is an error in grub_strtoull(), *end is not set. This differs from the usual behavior of strtoull(), and also means that some callers may use an uninitialized value for *end. Set *end unconditionally. Reference: http://git.savannah.gnu.org/cgit/grub.git/commit/?id=f41f0af48ab7f7c135aac17ac862c30bde0bbab7 Signed-off-by: Daniel Axtens Reviewed-by: Daniel Kiper --- grub-core/kern/misc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index dc5e10b..8f8a32d 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -466,6 +466,10 @@ grub_strtoull (const char * restrict str, const char ** const restrict end, { grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); + + if (end) + *end = (char *) str; + return ~0ULL; } @@ -476,6 +480,10 @@ grub_strtoull (const char * restrict str, const char ** const restrict end, if (! found) { grub_errno = GRUB_ERR_BAD_NUMBER; + + if (end) + *end = (char *) str; + return 0; } -- 2.19.1