From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751529AbdIOR3B (ORCPT ); Fri, 15 Sep 2017 13:29:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:45325 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751234AbdIOR3A (ORCPT ); Fri, 15 Sep 2017 13:29:00 -0400 Date: Fri, 15 Sep 2017 19:28:56 +0200 From: Michal =?UTF-8?B?U3VjaMOhbmVr?= To: Al Viro Cc: Tamara Diaconita , Baoquan He , Kamlakant Patel , Jonathan Corbet , Jani Nikula , Trond Myklebust , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Nicholas Piggin , Ingo Molnar , Mahesh Salgaonkar , Ilya Matveychikov , Paul Mackerras , Hari Bathini , Andrew Morton , Mauro Carvalho Chehab , linuxppc-dev@lists.ozlabs.org, Bamvor Jian Zhang Subject: Re: [PATCH 1/6] lib/cmdline.c: Add backslash support to kernel commandline parsing. Message-ID: <20170915192856.1d5708b6@kitsune.suse.cz> In-Reply-To: <20170915171409.GZ5426@ZenIV.linux.org.uk> References: <4fabdf584ad18d6aae61e331f783a5020567f634.1505231820.git.msuchanek@suse.de> <28da60231eb848981e858fa33e3b7e33f8547111.1505494668.git.msuchanek@suse.de> <20170915171409.GZ5426@ZenIV.linux.org.uk> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.31; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 15 Sep 2017 18:14:09 +0100 Al Viro wrote: > On Fri, Sep 15, 2017 at 07:02:46PM +0200, Michal Suchanek wrote: > > > for (i = 0; args[i]; i++) { > > - if (isspace(args[i]) && !in_quote) > > + if (isspace(args[i]) && !in_quote && !backslash) > > break; > > - if (equals == 0) { > > - if (args[i] == '=') > > - equals = i; > > + > > + if ((equals == 0) && (args[i] == '=')) > > + equals = i; > > + > > + if (!backslash) { > > + if ((args[i] == '"') || (args[i] == '\\')) > > { > > + if (args[i] == '"') > > + in_quote = !in_quote; > > + if (args[i] == '\\') > > + backslash = 1; > > + > > + memmove(args + 1, args, i); > > + args++; > > + i--; > > + } > > + } else { > > + backslash = 0; > > } > > - if (args[i] == '"') > > - in_quote = !in_quote; > > } > > ... and that makes for Unidiomatic Work With Strings Award for this > September. Using memmove() for string rewrite is almost always bad > taste; in this case it's also (as usual) broken. Care to share how it is broken? Thanks Michal