grub-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 2/2] util/resolve.c: Bail with error if moddep lst file line


From: Daniel Kiper
Subject: Re: [PATCH 2/2] util/resolve.c: Bail with error if moddep lst file line is too long
Date: Tue, 8 Feb 2022 17:07:23 +0100
User-agent: NeoMutt/20170113 (1.7.2)

On Wed, Jan 12, 2022 at 08:55:01PM -0600, Glenn Washburn wrote:
> The code reads each line into a buffer of size 1024 and does not check if
> the line is longer. So a line longer than 1024 will be read as a valid line
> followed by an invalid line. Then an error confusing to the user is sent
> with the test "invalid line format". But the line format is prefectly fine,
> the problem is in GRUB's parser. Check if we've hit a line longer than the
> size of the buffer, and if so send a more correct and reasonable error.
>
> Signed-off-by: Glenn Washburn <development@efficientek.com>
> ---
>  util/resolve.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/util/resolve.c b/util/resolve.c
> index 5e9afa10c..b0f2661f7 100644
> --- a/util/resolve.c
> +++ b/util/resolve.c
> @@ -127,6 +127,9 @@ read_dep_list (FILE *fp)
>         mod->next = dep->list;
>         dep->list = mod;
>       }
> +
> +     if ((p - buf) == sizeof (buf))
> +       grub_util_error (_("line too long, length greater than %lu: module 
> %s"), sizeof (buf), dep->name);

I had to replace "%lu" with "%zu". Otherwise Windows builds were broken.

Daniel



reply via email to

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