diff options
author | Timo Sirainen <cras@irssi.org> | 2000-07-23 12:47:14 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-07-23 12:47:14 +0000 |
commit | a3a066e9cf29a2542f2cf868ae4f6b14541f04ee (patch) | |
tree | 8f88c05906215145775286b6eda05ba9edddd0b9 /src | |
parent | f83f64b6bec477ab87d63fae3088199eb821b969 (diff) | |
download | irssi-a3a066e9cf29a2542f2cf868ae4f6b14541f04ee.zip |
Don't allow recursive aliases.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@517 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r-- | src/core/commands.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/core/commands.c b/src/core/commands.c index 31626a25..57e17592 100644 --- a/src/core/commands.c +++ b/src/core/commands.c @@ -36,6 +36,8 @@ char *current_command; static GSList *cmdget_funcs; static int signal_default_command; +static GSList *alias_runstack; + COMMAND_REC *command_find(const char *cmd) { GSList *tmp; @@ -572,6 +574,15 @@ void cmd_get_remove_func(CMD_GET_FUNC func) cmdget_funcs = g_slist_prepend(cmdget_funcs, (void *) func); } +#define alias_runstack_push(alias) \ + alias_runstack = g_slist_append(alias_runstack, alias) + +#define alias_runstack_pop(alias) \ + alias_runstack = g_slist_remove(alias_runstack, alias) + +#define alias_runstack_find(alias) \ + (gslist_find_icase_string(alias_runstack, alias) != NULL) + static void parse_command(const char *command, int expand_aliases, SERVER_REC *server, void *item) { @@ -582,10 +593,14 @@ static void parse_command(const char *command, int expand_aliases, args = strchr(cmd+8, ' '); if (args != NULL) *args++ = '\0'; else args = ""; - /* check if there's an alias for command */ - alias = expand_aliases ? alias_find(cmd+8) : NULL; + /* check if there's an alias for command. Don't allow + recursive aliases */ + alias = !expand_aliases || alias_runstack_find(cmd+8) ? NULL : + alias_find(cmd+8); if (alias != NULL) { + alias_runstack_push(cmd+8); eval_special_string(alias, args, server, item); + alias_runstack_pop(cmd+8); g_free(orig); return; } @@ -678,6 +693,7 @@ void commands_init(void) commands = NULL; cmdget_funcs = NULL; current_command = NULL; + alias_runstack = NULL; signal_default_command = signal_get_uniq_id("default command"); |