grub-devel
[Top][All Lists]
Advanced

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

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


From: Vladimir 'phcoder' Serbinenko
Subject: Re: [PATCH] misc: Set grub_errno on all failures in grub_xvasprintf()
Date: Sat, 2 Sep 2023 22:03:08 +0200

2 problems:
1) Did you audit that all call places either clear or propagate error?
2) We use standard error message "out of memory". This allows it to be translated and not be too technical.

Le sam. 2 sept. 2023, 04:17, Glenn Washburn <development@efficientek.com> a écrit :
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


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

reply via email to

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