grub-devel
[Top][All Lists]
Advanced

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

Re: two bugs in configfile parser


From: Bean
Subject: Re: two bugs in configfile parser
Date: Sat, 2 Aug 2008 00:49:30 +0800

On Fri, Aug 1, 2008 at 7:44 AM, Patrick Georgi <address@hidden> wrote:
> Hi,
>
> given the following grub.cfg (simplified test case):
>
> menuentry "test" {
> if test "a" = "a" ; then
>  echo foo
> fi
> }
>
> I have some issues. To reproduce, load grub with that file, enter the editor
> on the menu item, run it with ctrl-x.
> Two things can happen (I have some local patches which lead to one happening
> slightly more often than the other, so it seems to be quite sensitive to
> $whatever):
>
>  1. it crashes on malloc magic problems. It seems to be related to the
> leading spaces on "echo foo". If I remove them, it works. I guess, they're
> skipped at some place, and after that, the string should be grub_free()d.
> grub's mm doesn't support that.
>
>  2. it corrupts the text once it finishes. After removing the leading
> spaces, it runs correctly and returns to the editor. Unfortunately, starting
> with "  echo foo", the text is corrupted. Another run (with all those
> garbage strings) ends in malloc magic error.
>
> That code runs fine if executed directly from the menu.

Hi,

Ok, I've found the bug. In editor_getline (normal/menu_entry.c), it
should return a string allocated with grub_strdup, instead of the
original one, as the result will be release in the lexer once it's
done.


-- 
Bean

Attachment: getline.diff
Description: Text Data


reply via email to

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