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

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