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

Robert Ancell robert.ancell at gmail.com
Thu Jun 19 20:24:00 PDT 2014


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


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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20140620/31f474ee/attachment.html>


More information about the wayland-devel mailing list