weston-launch: Don't segfault if passed no arguments

Probably not exploitable since I think Linux always puts NULL there,
but let's actually check.
This commit is contained in:
Colin Walters 2013-08-30 08:26:31 -04:00
parent deeb1db1ac
commit 7bd4e6ecb0

View File

@ -737,6 +737,8 @@ main(int argc, char *argv[])
if ((argc - optind) > (MAX_ARGV_SIZE - 6)) if ((argc - optind) > (MAX_ARGV_SIZE - 6))
error(1, E2BIG, "Too many arguments to pass to weston"); error(1, E2BIG, "Too many arguments to pass to weston");
if (optind >= argc)
error(1, 0, "Expected program argument");
if (strcmp (argv[optind], "mutter-wayland") && if (strcmp (argv[optind], "mutter-wayland") &&
strcmp (argv[optind], "gnome-shell-wayland")) strcmp (argv[optind], "gnome-shell-wayland"))
error(1, 0, "mutter-launch can only be used to launch mutter or gnome-shell"); error(1, 0, "mutter-launch can only be used to launch mutter or gnome-shell");