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: Daniel Kiper
Subject: Re: [PATCH] misc: Set grub_errno on all failures in grub_xvasprintf()
Date: Sat, 2 Sep 2023 20:29:40 +0200
User-agent: NeoMutt/20170113 (1.7.2)

On Fri, Sep 01, 2023 at 09:16:24PM -0500, Glenn Washburn wrote:
> 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>

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.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);

Nit, s/grub_xvasprintf/grub_xvasprintf()/...

Daniel



reply via email to

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