All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] misc: Set grub_errno on all failures in grub_xvasprintf()
@ 2023-09-02  2:16 Glenn Washburn
  2023-09-02 18:29 ` Daniel Kiper
  2023-09-02 20:03 ` Vladimir 'phcoder' Serbinenko
  0 siblings, 2 replies; 4+ messages in thread
From: Glenn Washburn @ 2023-09-02  2:16 UTC (permalink / raw)
  To: grub-devel, Daniel Kiper; +Cc: Glenn Washburn

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-10-06  6:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-02  2:16 [PATCH] misc: Set grub_errno on all failures in grub_xvasprintf() Glenn Washburn
2023-09-02 18:29 ` Daniel Kiper
2023-09-02 20:03 ` Vladimir 'phcoder' Serbinenko
2023-10-06  6:23   ` Glenn Washburn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.