[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:23:04 PDT 2014


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