grub-devel
[Top][All Lists]
Advanced

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

[PATCH] misc: Set grub_errno on all failures in grub_xvasprintf()


From: Glenn Washburn
Subject: [PATCH] misc: Set grub_errno on all failures in grub_xvasprintf()
Date: Fri, 1 Sep 2023 21:16:24 -0500

When failing to allocate the preallocate buffer, grub_xvasprintf()
returns NULL, but does not set grub_errno. Returning NULL is sufficient
for a caller to determine there was an error. However, some usages of
grub_xvasprintf() check for a NULL return value and then return
grub_errno, which could return some previously set error code or
potentially even a success code.

Signed-off-by: Glenn Washburn <development@efficientek.com>
---
 grub-core/kern/misc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
index b57249acb81b..afb41bd63a6a 100644
--- a/grub-core/kern/misc.c
+++ b/grub-core/kern/misc.c
@@ -1232,6 +1232,7 @@ grub_xvasprintf (const char *fmt, va_list ap)
       if (!ret)
        {
          free_printf_args (&args);
+         grub_error (GRUB_ERR_OUT_OF_MEMORY, "grub_xvasprintf failed to 
allocate memory of size %" PRIuGRUB_SIZE, as);
          return NULL;
        }
 
-- 
2.34.1




reply via email to

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