dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

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

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