1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

cmd_executable(): Check arg lengths

This commit is contained in:
Michael Vetter 2020-07-01 16:10:27 +02:00
parent 8be1e44cea
commit 780ee74177

View File

@ -9156,12 +9156,22 @@ cmd_executable(ProfWin *window, const char *const command, gchar **args)
prefs_set_string(PREF_AVATAR_CMD, args[1]); prefs_set_string(PREF_AVATAR_CMD, args[1]);
cons_show("Avatar command set to: %s", args[1]); cons_show("Avatar command set to: %s", args[1]);
} else if (g_strcmp0(args[0], "urlopen") == 0) { } else if (g_strcmp0(args[0], "urlopen") == 0) {
if (g_strv_length(args) < 4) {
cons_bad_cmd_usage(command);
return TRUE;
}
char *str = g_strjoinv(" ", &args[3]); char *str = g_strjoinv(" ", &args[3]);
const gchar* const list[] = {args[2], str, NULL}; const gchar* const list[] = {args[2], str, NULL};
prefs_set_string_list_with_option(PREF_URL_OPEN_CMD, args[1], list); prefs_set_string_list_with_option(PREF_URL_OPEN_CMD, args[1], list);
cons_show("`url open` command set to: %s for %s files", str, args[1]); cons_show("`url open` command set to: %s for %s files", str, args[1]);
g_free(str); g_free(str);
} else if (g_strcmp0(args[0], "urlsave") == 0) { } else if (g_strcmp0(args[0], "urlsave") == 0) {
if (g_strv_length(args) < 3) {
cons_bad_cmd_usage(command);
return TRUE;
}
char *str = g_strjoinv(" ", &args[2]); char *str = g_strjoinv(" ", &args[2]);
prefs_set_string_with_option(PREF_URL_SAVE_CMD, args[1], str); prefs_set_string_with_option(PREF_URL_SAVE_CMD, args[1], str);
cons_show("`url save` command set to: %s for scheme %s", str, args[1]); cons_show("`url save` command set to: %s for scheme %s", str, args[1]);