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

44 lines
1.2 KiB
Diff
Raw Normal View History

2021-03-02 18:56:20 +00:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Daniel Axtens <dja@axtens.net>
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.
Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
---
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
2021-05-18 06:38:48 +00:00
index 97378c48b22..475f3e0ef05 100644
2021-03-02 18:56:20 +00:00
--- a/grub-core/kern/misc.c
+++ b/grub-core/kern/misc.c
2021-05-18 06:38:48 +00:00
@@ -485,6 +485,10 @@ grub_strtoull (const char *str, const char ** const end, int base)
2021-03-02 18:56:20 +00:00
{
grub_error (GRUB_ERR_OUT_OF_RANGE,
N_("overflow is detected"));
+
+ if (end)
+ *end = (char *) str;
+
return ~0ULL;
}
2021-05-18 06:38:48 +00:00
@@ -496,6 +500,10 @@ grub_strtoull (const char *str, const char ** const end, int base)
2021-03-02 18:56:20 +00:00
{
grub_error (GRUB_ERR_BAD_NUMBER,
N_("unrecognized number"));
+
+ if (end)
+ *end = (char *) str;
+
return 0;
}