diff options
author | Michael Vetter <jubalh@iodoru.org> | 2019-06-05 14:41:09 +0200 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2019-06-05 14:41:09 +0200 |
commit | 4e972f8aef4a514928e7ffd56e8d31c7bef37b13 (patch) | |
tree | dbf69885e9f78f6acaf7234d9e30b5e82bb01e9b /src/command/cmd_funcs.c | |
parent | 53ef20927268b777c4845984593bc32a066a1e68 (diff) | |
download | profani-tty-4e972f8aef4a514928e7ffd56e8d31c7bef37b13.tar.gz |
Check for sane argument in autoconnect set
Check that user doesnt do `/autoconnect set `. Which would result in: `Account '(null)' does not exist`.
Diffstat (limited to 'src/command/cmd_funcs.c')
-rw-r--r-- | src/command/cmd_funcs.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index d44f9d68..f2c9aa1d 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -6555,11 +6555,15 @@ cmd_autoconnect(ProfWin *window, const char *const command, gchar **args) prefs_set_string(PREF_CONNECT_ACCOUNT, NULL); cons_show("Autoconnect account disabled."); } else if (strcmp(args[0], "set") == 0) { - if (accounts_account_exists(args[1])) { - prefs_set_string(PREF_CONNECT_ACCOUNT, args[1]); - cons_show("Autoconnect account set to: %s.", args[1]); + if (args[1] == NULL || strlen(args[1]) == 0) { + cons_bad_cmd_usage(command); } else { - cons_show_error("Account '%s' does not exist.", args[1]); + if (accounts_account_exists(args[1])) { + prefs_set_string(PREF_CONNECT_ACCOUNT, args[1]); + cons_show("Autoconnect account set to: %s.", args[1]); + } else { + cons_show_error("Account '%s' does not exist.", args[1]); + } } } else { cons_bad_cmd_usage(command); |