From 797ca99f42a05e6f2b491983cd7f0222b9bfc519 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 14 Apr 2019 16:39:14 +0100 Subject: [PATCH] Detect infinite alias self-recursion mixed with other commands, such as in the case of `alias a "echo test; a"; a`. (Unfortunately, this does not work if "wait" is used instead of "echo", but oh well) --- src/command.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/command.c b/src/command.c index ba0095e0..fda17847 100644 --- a/src/command.c +++ b/src/command.c @@ -514,7 +514,6 @@ static void COM_ExecuteString(char *ptext) { if (!stricmp(com_argv[0], cmd->name)) //case insensitive now that we have lower and uppercase! { - recursion = 0; cmd->function(); return; } @@ -526,19 +525,17 @@ static void COM_ExecuteString(char *ptext) if (!stricmp(com_argv[0], a->name)) { if (recursion > MAX_ALIAS_RECURSION) - { CONS_Alert(CONS_WARNING, M_GetText("Alias recursion cycle detected!\n")); - recursion = 0; - return; + else + { // Monster Iestyn: keep track of how many levels of recursion we're in + recursion++; + COM_BufInsertText(a->value); + recursion--; } - recursion++; - COM_BufInsertText(a->value); return; } } - recursion = 0; - // check cvars // Hurdler: added at Ebola's request ;) // (don't flood the console in software mode with bad gr_xxx command)