From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MWjYd-0003l5-8Q for mharc-grub-devel@gnu.org; Fri, 31 Jul 2009 00:17:27 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MWjYb-0003jZ-GN for grub-devel@gnu.org; Fri, 31 Jul 2009 00:17:25 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MWjYW-0003fd-L3 for grub-devel@gnu.org; Fri, 31 Jul 2009 00:17:25 -0400 Received: from [199.232.76.173] (port=48740 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MWjYW-0003fT-6X for grub-devel@gnu.org; Fri, 31 Jul 2009 00:17:20 -0400 Received: from c60.cesmail.net ([216.154.195.49]:52553) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.60) (envelope-from ) id 1MWjYW-00025X-1G for grub-devel@gnu.org; Fri, 31 Jul 2009 00:17:20 -0400 Received: from unknown (HELO smtprelay2.cesmail.net) ([192.168.1.112]) by c60.cesmail.net with ESMTP; 31 Jul 2009 00:17:17 -0400 Received: from [192.168.1.151] (c-69-141-194-35.hsd1.pa.comcast.net [69.141.194.35]) by smtprelay2.cesmail.net (Postfix) with ESMTPSA id AB55B34C6A for ; Fri, 31 Jul 2009 00:29:05 -0400 (EDT) From: Pavel Roskin To: The development of GRUB 2 In-Reply-To: References: Content-Type: text/plain Date: Fri, 31 Jul 2009 00:17:03 -0400 Message-Id: <1249013823.6669.20.camel@ct> Mime-Version: 1.0 X-Mailer: Evolution 2.26.3 (2.26.3-1.fc11) Content-Transfer-Encoding: 7bit X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: Re: [BUGFIX] Incorrect count of argument with rescue parser X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Jul 2009 04:17:25 -0000 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 ) 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
(gdb) -- Regards, Pavel Roskin