From: Glenn Washburn <development@efficientek.com>
To: grub-devel@gnu.org, Daniel Kiper <dkiper@net-space.pl>
Cc: Glenn Washburn <development@efficientek.com>
Subject: [PATCH] misc: Set grub_errno on all failures in grub_xvasprintf()
Date: Fri, 1 Sep 2023 21:16:24 -0500 [thread overview]
Message-ID: <20230902021624.3518323-1-development@efficientek.com> (raw)
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
next reply other threads:[~2023-09-02 2:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-02 2:16 Glenn Washburn [this message]
2023-09-02 18:29 ` [PATCH] misc: Set grub_errno on all failures in grub_xvasprintf() Daniel Kiper
2023-09-02 20:03 ` Vladimir 'phcoder' Serbinenko
2023-10-06 6:23 ` Glenn Washburn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230902021624.3518323-1-development@efficientek.com \
--to=development@efficientek.com \
--cc=dkiper@net-space.pl \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.