From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1f6Bb9-0000yU-8C for mharc-grub-devel@gnu.org; Wed, 11 Apr 2018 04:59:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59491) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6Bb6-0000rR-G2 for grub-devel@gnu.org; Wed, 11 Apr 2018 04:59:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f6Bb1-0006Vv-LX for grub-devel@gnu.org; Wed, 11 Apr 2018 04:59:20 -0400 Received: from victor.provo.novell.com ([137.65.250.26]:47049 helo=prv3-mh.provo.novell.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f6Bb1-0006VD-DA for grub-devel@gnu.org; Wed, 11 Apr 2018 04:59:15 -0400 Received: from mazu (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by prv3-mh.provo.novell.com with ESMTP (TLS encrypted); Wed, 11 Apr 2018 02:58:58 -0600 Date: Wed, 11 Apr 2018 16:58:54 +0800 From: Michael Chang To: grub-devel@gnu.org Subject: [PATCH] pass kernel command line as verbatim Message-ID: <20180411085854.vjhgkax6ue7ecius@mazu> Mail-Followup-To: grub-devel@gnu.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: NeoMutt/20170421 (1.8.2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 137.65.250.26 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Apr 2018 08:59:21 -0000 The command line has been processed by grub shell, then the result is expected to be passed to kernel command line as verbatim according to the grub manual [1][2]. This patch removes extra escape character added as it helps nothing but only creates trouble as you want them to be literal. Besides the surrounding double-quotes added is kept as it used to protect space. [1] https://www.gnu.org/software/grub/manual/grub/html_node/linux.html#linux [2] https://www.gnu.org/software/grub/manual/grub/html_node/xen_005fhypervisor.html Signed-off-by: Michael Chang --- grub-core/lib/cmdline.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/grub-core/lib/cmdline.c b/grub-core/lib/cmdline.c index d5e10ee87..26b8131c8 100644 --- a/grub-core/lib/cmdline.c +++ b/grub-core/lib/cmdline.c @@ -27,9 +27,7 @@ static unsigned int check_arg (char *c, int *has_space) while (*c) { - if (*c == '\\' || *c == '\'' || *c == '"') - size++; - else if (*c == ' ') + if (*c == ' ') space = 1; size++; @@ -84,13 +82,7 @@ int grub_create_loader_cmdline (int argc, char *argv[], char *buf, *buf++ = '"'; while (*c) - { - if (*c == '\\' || *c == '\'' || *c == '"') - *buf++ = '\\'; - - *buf++ = *c; - c++; - } + *buf++ = *c++; if (space) *buf++ = '"'; -- 2.16.1