From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753362AbdHUK1U (ORCPT ); Mon, 21 Aug 2017 06:27:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52146 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752533AbdHUK1S (ORCPT ); Mon, 21 Aug 2017 06:27:18 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 64B0485547 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=bhe@redhat.com Date: Mon, 21 Aug 2017 18:27:12 +0800 From: Baoquan He To: Michal Suchanek Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Jonathan Corbet , Jessica Yu , Rusty Russell , Jason Baron , Hari Bathini , Mahesh J Salgaonkar , Daniel Axtens , Andrew Morton , Thiago Jung Bauermann , Balbir Singh , Nicholas Piggin , Michael Neuling , "Aneesh Kumar K.V" , Christophe Leroy , Scott Wood , "Oliver O'Halloran" , David Howells , "Sylvain 'ythier' Hitier" , Ingo Molnar , Kees Cook , Thomas Gleixner , "Steven Rostedt," , Viresh Kumar , Tejun Heo , Lokesh Vutla , Ilya Matveychikov , linuxppc-dev@lists.ozlabs.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v7 3/4] lib/cmdline.c Remove quotes symmetrically. Message-ID: <20170821102712.GF20615@x1> References: <78655b3689f6cd0c76b787b8ef2c824ef75a99a5.1503000577.git.msuchanek@suse.de> <0e0a8ad11e2c9c7db02baa1bbb5a30f429586854.1503000577.git.msuchanek@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0e0a8ad11e2c9c7db02baa1bbb5a30f429586854.1503000577.git.msuchanek@suse.de> User-Agent: Mutt/1.7.0 (2016-08-17) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 21 Aug 2017 10:27:18 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/17/17 at 10:14pm, Michal Suchanek wrote: > Remove quotes from argument value only if there is qoute on both sides. > > Signed-off-by: Michal Suchanek Sounds reasonable. Just for curiosity, do we have chance to pass in option with a single '"'? > --- > arch/powerpc/kernel/fadump.c | 6 ++---- > lib/cmdline.c | 7 ++----- > 2 files changed, 4 insertions(+), 9 deletions(-) > > diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c > index a1614d9b8a21..d7da4ce9f7ae 100644 > --- a/arch/powerpc/kernel/fadump.c > +++ b/arch/powerpc/kernel/fadump.c > @@ -489,10 +489,8 @@ static void __init fadump_update_params(struct param_info *param_info, > *tgt++ = ' '; > > /* next_arg removes one leading and one trailing '"' */ > - if (*tgt == '"') > - shortening += 1; > - if (*(tgt + vallen + shortening) == '"') > - shortening += 1; > + if ((*tgt == '"') && (*(tgt + vallen + shortening) == '"')) > + shortening += 2; > > /* remove one leading and one trailing quote if both are present */ > if ((val[0] == '"') && (val[vallen - 1] == '"')) { > diff --git a/lib/cmdline.c b/lib/cmdline.c > index 4c0888c4a68d..01e701b2afe8 100644 > --- a/lib/cmdline.c > +++ b/lib/cmdline.c > @@ -227,14 +227,11 @@ char *next_arg(char *args, char **param, char **val) > *val = args + equals + 1; > > /* Don't include quotes in value. */ > - if (**val == '"') { > + if ((**val == '"') && (args[i-1] == '"')) { > (*val)++; > - if (args[i-1] == '"') > - args[i-1] = '\0'; > + args[i-1] = '\0'; > } > } > - if (quoted && args[i-1] == '"') > - args[i-1] = '\0'; > > if (args[i]) { > args[i] = '\0'; > -- > 2.10.2 >