All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Marzinski <bmarzins@redhat.com>
To: Martin Wilck <martin.wilck@suse.com>
Cc: "dm-devel@redhat.com" <dm-devel@redhat.com>
Subject: Re: [dm-devel] [PATCH 1/3] libmpathutil: simplify set_value
Date: Wed, 14 Dec 2022 09:28:56 -0600	[thread overview]
Message-ID: <20221214152856.GB6245@octiron.msp.redhat.com> (raw)
In-Reply-To: <2329a2afe95f32ba6520932cdf32c510980b6a88.camel@suse.com>

On Wed, Dec 14, 2022 at 09:19:45AM +0000, Martin Wilck wrote:
> On Tue, 2022-12-13 at 17:36 -0600, Benjamin Marzinski wrote:
> > alloc_strvec() will never create a strvec with multiple tokens
> > between
> > the quote tokens.  Verify this in validate_config_strvec(), and
> > simplify
> > set_value() by only reading one value after a quote token.
> > 
> > Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
> 
> One suggestion below
> 
> 
> > @@ -496,6 +470,10 @@ validate_config_strvec(vector strvec, const char
> > *file)
> >                         if (VECTOR_SIZE(strvec) > i + 1)
> >                                 condlog(0, "ignoring extra data
> > starting with '%s' on line %d of %s", (char *)VECTOR_SLOT(strvec, (i
> > + 1)), line_nr, file);
> >                         return 0;
> > +               } else if (i > 3) {
> > +                       /* There should only ever be one token
> > between quotes */
> > +                       condlog(0, "parsing error starting with '%s'
> > on line %d of %s", str, line_nr, file);
> > +                       return -1;
> >                 }
> >         }
> >         condlog(0, "missing closing quotes on line %d of %s",
> 
> This could be further simplified. We know that strvec[1] is a quote. So
> the only valid possibilities are
> 
>  - strvec[2] is a quote (-> empty string)
>  - strvec[2] is not a quote and strvec[3] is a quote
> 
> The code would be better understandable if we just spell out these
> possibilities rather than using a loop that start at 2 and is left at 3
> already.

Makes sense.

-Ben

> 
> Martin
> 
> 
> 
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


  reply	other threads:[~2022-12-14 15:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-13 23:36 [dm-devel] [PATCH 0/3] multipath config fixes Benjamin Marzinski
2022-12-13 23:36 ` [dm-devel] [PATCH 1/3] libmpathutil: simplify set_value Benjamin Marzinski
2022-12-14  9:19   ` Martin Wilck
2022-12-14 15:28     ` Benjamin Marzinski [this message]
2022-12-13 23:36 ` [dm-devel] [PATCH 2/3] libmultipath: don't leak memory on invalid strings Benjamin Marzinski
2022-12-14  9:21   ` Martin Wilck
2022-12-13 23:36 ` [dm-devel] [PATCH 3/3] libmutipath: validate the argument count of config strings Benjamin Marzinski
2022-12-14  9:41   ` Martin Wilck
2022-12-14 16:12     ` Benjamin Marzinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221214152856.GB6245@octiron.msp.redhat.com \
    --to=bmarzins@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=martin.wilck@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.