Blame SOURCES/0433-kern-misc-Always-set-end-in-grub_strtoull.patch

468bd4
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
468bd4
From: Daniel Axtens <dja@axtens.net>
468bd4
Date: Wed, 13 Jan 2021 22:19:01 +1100
468bd4
Subject: [PATCH] kern/misc: Always set *end in grub_strtoull()
468bd4
468bd4
Currently, if there is an error in grub_strtoull(), *end is not set.
468bd4
This differs from the usual behavior of strtoull(), and also means that
468bd4
some callers may use an uninitialized value for *end.
468bd4
468bd4
Set *end unconditionally.
468bd4
468bd4
Signed-off-by: Daniel Axtens <dja@axtens.net>
468bd4
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
468bd4
---
468bd4
 grub-core/kern/misc.c | 8 ++++++++
468bd4
 1 file changed, 8 insertions(+)
468bd4
468bd4
diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
f6e916
index 97378c48b..475f3e0ef 100644
468bd4
--- a/grub-core/kern/misc.c
468bd4
+++ b/grub-core/kern/misc.c
468bd4
@@ -485,6 +485,10 @@ grub_strtoull (const char *str, const char ** const end, int base)
468bd4
 	{
468bd4
 	  grub_error (GRUB_ERR_OUT_OF_RANGE,
468bd4
 		      N_("overflow is detected"));
468bd4
+
468bd4
+          if (end)
468bd4
+            *end = (char *) str;
468bd4
+
468bd4
 	  return ~0ULL;
468bd4
 	}
468bd4
 
468bd4
@@ -496,6 +500,10 @@ grub_strtoull (const char *str, const char ** const end, int base)
468bd4
     {
468bd4
       grub_error (GRUB_ERR_BAD_NUMBER,
468bd4
 		  N_("unrecognized number"));
468bd4
+
468bd4
+      if (end)
468bd4
+        *end = (char *) str;
468bd4
+
468bd4
       return 0;
468bd4
     }
468bd4