grub-devel
[Top][All Lists]
Advanced

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

Re: [BUGFIX] Incorrect count of argument with rescue parser


From: Pavel Roskin
Subject: Re: [BUGFIX] Incorrect count of argument with rescue parser
Date: Fri, 31 Jul 2009 00:17:03 -0400

On Fri, 2009-07-31 at 00:46 +0200, Vladimir 'phcoder' Serbinenko wrote:
> This patch fixes the parsing of two strings like following ones:
> "echo 1 " was parsed into "echo", "1", ""
> "echo $root" was parsed into "echo" (variable just disappeared)

It would be helpful if you explain how to see the difference without
tracing grub_parser_split_cmdline() in the debugger.

Also, it would be great if you explain the change.  A comment for the
newly added code would help understand it.  Otherwise it looks like the
previous comment still applies ("A special case for when the last
character was part of a variable").

Since you looked at the problem, perhaps you know why argc is
decremented before the exit.  I think it needs a comment.

Also, grub_malloc() appears to allocate two extra pointers for argv (if
we consider that argc is decremented).  argv is not supposed to be null
terminated.  I'd rather allocate just enough memory so that we could
catch abusers by running grub-emu in valgrind.

Anyway, the patch doesn't pass even minimal testing.  Pressing Tab in
grub-emu crashes it at normal/completion.c:424

(gdb) where
#0  0x00000000004179d1 in grub_normal_do_completion (buf=0x7fff5d5a29d0 "", 
    restore=0x7fff5d5a304c, hook=0x41568e <print_completion>) at 
normal/completion.c:424
#1  0x00000000004159d1 in grub_cmdline_get (prompt=0x7fff5d5a30e0 "sh:grub> ", 
    cmdline=0x662fa0 "", readline=1) at normal/cmdline.c:329
#2  0x0000000000418813 in grub_normal_read_line (line=0x7fff5d5a3160, cont=0)
    at normal/main.c:504
#3  0x00000000004141b3 in grub_reader_loop (getline=0) at kern/reader.c:43
#4  0x00000000004117f4 in grub_main () at kern/main.c:176
#5  0x00000000004397ab in main (argc=3, argv=0x7fff5d5a32c8) at 
util/grub-emu.c:236
(gdb) l
419         {
420           /* Complete a command.  */
421           if (grub_command_iterate (iterate_command))
422             goto fail;
423         }
424       else if (*current_word == '-')
425         {
426           if (complete_arguments (buf))
427             goto fail;
428         }
(gdb) p current_word
$1 = 0x21 <Address 0x21 out of bounds>
(gdb)

-- 
Regards,
Pavel Roskin




reply via email to

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