diff options
-rw-r--r-- | src/core/commands.c | 6 | ||||
-rw-r--r-- | src/core/commands.h | 3 | ||||
-rw-r--r-- | src/fe-common/core/fe-core-commands.c | 3 | ||||
-rw-r--r-- | src/fe-common/core/module-formats.c | 1 | ||||
-rw-r--r-- | src/fe-common/core/module-formats.h | 1 |
5 files changed, 12 insertions, 2 deletions
diff --git a/src/core/commands.c b/src/core/commands.c index 17b825b5..d9dc67af 100644 --- a/src/core/commands.c +++ b/src/core/commands.c @@ -945,12 +945,18 @@ static void event_command(const char *line, SERVER_REC *server, void *item) parse_command(line, expand_aliases, server, item); } +static int eval_recursion_depth=0; /* SYNTAX: EVAL <command(s)> */ static void cmd_eval(const char *data, SERVER_REC *server, void *item) { g_return_if_fail(data != NULL); + if (eval_recursion_depth > 100) + cmd_return_error(CMDERR_EVAL_MAX_RECURSE); + + eval_recursion_depth++; eval_special_string(data, "", server, item); + eval_recursion_depth--; } /* SYNTAX: CD <directory> */ diff --git a/src/core/commands.h b/src/core/commands.h index b4f4ea0e..0dda9f61 100644 --- a/src/core/commands.h +++ b/src/core/commands.h @@ -39,7 +39,8 @@ enum { CMDERR_ILLEGAL_PROTO, /* requires different chat protocol than the active server */ CMDERR_NOT_GOOD_IDEA, /* not good idea to do, -yes overrides this */ CMDERR_INVALID_TIME, /* invalid time specification */ - CMDERR_INVALID_CHARSET /* invalid charset specification */ + CMDERR_INVALID_CHARSET, /* invalid charset specification */ + CMDERR_EVAL_MAX_RECURSE /* eval hit recursion limit */ }; /* Return the full command for `alias' */ diff --git a/src/fe-common/core/fe-core-commands.c b/src/fe-common/core/fe-core-commands.c index dd788a91..545cf027 100644 --- a/src/fe-common/core/fe-core-commands.c +++ b/src/fe-common/core/fe-core-commands.c @@ -49,7 +49,8 @@ static int ret_texts[] = { TXT_ILLEGAL_PROTO, TXT_NOT_GOOD_IDEA, TXT_INVALID_TIME, - TXT_INVALID_CHARSET + TXT_INVALID_CHARSET, + TXT_EVAL_MAX_RECURSE }; int command_hide_output; diff --git a/src/fe-common/core/module-formats.c b/src/fe-common/core/module-formats.c index 6d13ed08..66fb9f91 100644 --- a/src/fe-common/core/module-formats.c +++ b/src/fe-common/core/module-formats.c @@ -219,6 +219,7 @@ FORMAT_REC fecommon_core_formats[] = { { "invalid_level", "Invalid message level", 0 }, { "invalid_size", "Invalid size", 0 }, { "invalid_charset", "Invalid charset: $0", 1, { 0 } }, + { "eval_max_recurse", "/eval hit maximum recursion limit", 0 }, /* ---- */ { NULL, "Themes", 0 }, diff --git a/src/fe-common/core/module-formats.h b/src/fe-common/core/module-formats.h index ea9af5d2..55ea9df0 100644 --- a/src/fe-common/core/module-formats.h +++ b/src/fe-common/core/module-formats.h @@ -188,6 +188,7 @@ enum { TXT_INVALID_LEVEL, TXT_INVALID_SIZE, TXT_INVALID_CHARSET, + TXT_EVAL_MAX_RECURSE, TXT_FILL_11, |