All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Roskin <proski@gnu.org>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: [BUGFIX] Incorrect count of argument with rescue parser
Date: Fri, 31 Jul 2009 00:17:03 -0400	[thread overview]
Message-ID: <1249013823.6669.20.camel@ct> (raw)
In-Reply-To: <d7ead6de0907301546g72c5a8bv7201e1a7321cc3f6@mail.gmail.com>

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	other threads:[~2009-07-31  4:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-30 22:46 [BUGFIX] Incorrect count of argument with rescue parser Vladimir 'phcoder' Serbinenko
2009-07-31  4:17 ` Pavel Roskin [this message]
2009-07-31  9:00   ` Vladimir 'phcoder' Serbinenko

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=1249013823.6669.20.camel@ct \
    --to=proski@gnu.org \
    --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.