[PATCH] option-parser: Don't read off the end of string options without an '='

Pekka Paalanen ppaalanen at gmail.com
Wed Aug 20 05:37:26 PDT 2014


On Fri, 20 Jun 2014 15:23:59 +1200
Robert Ancell <robert.ancell at gmail.com> wrote:

> I'm not sure if the expected behaviour is for:
> $ weston --shell foo.so
> to work, if so the patch can be modified.

Ah, sorry for not noticing this patch in time.
What do you think of Bill's series here:
http://lists.freedesktop.org/archives/wayland-devel/2014-August/016657.html


Thanks,
pq

> On 20 June 2014 15:22, Robert Ancell <robert.ancell at gmail.com> wrote:
> 
> > On my system:
> > $ weston --shell
> > would use the first environment variable as the argument to --shell
> > and
> > $ weston --shell foo.so
> > Would use foo.so as the argument and then parse foo.so as a new option.
> > ---
> >  shared/option-parser.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/shared/option-parser.c b/shared/option-parser.c
> > index c00349a..bddaccb 100644
> > --- a/shared/option-parser.c
> > +++ b/shared/option-parser.c
> > @@ -66,7 +66,7 @@ parse_options(const struct weston_option *options,
> >                             argv[i][1] == '-' &&
> >                             strncmp(options[k].name, &argv[i][2], len) ==
> > 0 &&
> >                             (argv[i][len + 2] == '=' || argv[i][len + 2]
> > == '\0')) {
> > -                               handle_option(&options[k], &argv[i][len +
> > 3]);
> > +                               handle_option(&options[k], argv[i][len +
> > 2] == '=' ? &argv[i][len + 3] : &argv[i][len + 2]);
> >                                 break;
> >                         } else if (options[k].short_name &&
> >                                    argv[i][0] == '-' &&
> > --
> > 2.0.0
> >
> >



More information about the wayland-devel mailing list