Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1732973
| From | Michal Suchánek <msuchanek@suse.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 1/6] lib/cmdline.c: Add backslash support to kernel commandline parsing. |
| Date | 2017-09-15 19:30 +0200 |
| Message-ID | <uq2Bb-61b-11@gated-at.bofh.it> (permalink) |
| References | <uoVV8-3tT-21@gated-at.bofh.it> <uq2hP-5TN-3@gated-at.bofh.it> <uq2rv-5Xm-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Fri, 15 Sep 2017 18:14:09 +0100
Al Viro <viro@ZenIV.linux.org.uk> 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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v8 6/6] powerpc/fadump: use the new parse_args callback arguments Michal Suchanek <msuchanek@suse.de> - 2017-09-12 18:10 +0200
[PATCH 1/6] lib/cmdline.c: Add backslash support to kernel commandline parsing. Michal Suchanek <msuchanek@suse.de> - 2017-09-15 19:10 +0200
Re: [PATCH 1/6] lib/cmdline.c: Add backslash support to kernel commandline parsing. Al Viro <viro@ZenIV.linux.org.uk> - 2017-09-15 19:20 +0200
Re: [PATCH 1/6] lib/cmdline.c: Add backslash support to kernel commandline parsing. Michal Suchánek <msuchanek@suse.de> - 2017-09-15 19:30 +0200
Re: [PATCH 1/6] lib/cmdline.c: Add backslash support to kernel commandline parsing. Michal Suchánek <msuchanek@suse.de> - 2017-09-25 20:50 +0200
csiph-web