From: Daniel Axtens Date: Wed, 13 Jan 2021 11:19:01 +0000 (+1100) Subject: kern/misc: Always set *end in grub_strtoull() X-Git-Tag: grub-2.06-rc1~77 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f41f0af48ab7f7c135aac17ac862c30bde0bbab7;p=thirdparty%2Fgrub.git 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. Signed-off-by: Daniel Axtens Reviewed-by: Daniel Kiper --- diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index a278e069b..430e72340 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -419,6 +419,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; } @@ -430,6 +434,10 @@ grub_strtoull (const char * restrict str, const char ** const restrict end, { grub_error (GRUB_ERR_BAD_NUMBER, N_("unrecognized number")); + + if (end) + *end = (char *) str; + return 0; }