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