grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SECURITY PATCH 066/117] kern/misc: Always set *end in grub_strtoull()


From: Daniel Kiper
Subject: [SECURITY PATCH 066/117] kern/misc: Always set *end in grub_strtoull()
Date: Tue, 2 Mar 2021 19:01:13 +0100

From: Daniel Axtens <dja@axtens.net>

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
index a278e069b..430e72340 100644
--- a/grub-core/kern/misc.c
+++ b/grub-core/kern/misc.c
@@ -419,6 +419,10 @@ grub_strtoull (const char * restrict str, const char ** 
const restrict end,
        {
          grub_error (GRUB_ERR_OUT_OF_RANGE,
                      N_("overflow is detected"));
+
+          if (end)
+            *end = (char *) str;
+
          return ~0ULL;
        }
 
@@ -430,6 +434,10 @@ grub_strtoull (const char * restrict str, const char ** 
const restrict end,
     {
       grub_error (GRUB_ERR_BAD_NUMBER,
                  N_("unrecognized number"));
+
+      if (end)
+        *end = (char *) str;
+
       return 0;
     }
 
-- 
2.11.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]