From 5e5a48606f02af80e67bbaf662b8c6c4c8e15004 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Thu, 10 Jun 2021 20:29:25 -0400 Subject: [PATCH] CmdExec: Prevent user from executing an empty command Closes #2503. --- src/commands/CmdExec.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/commands/CmdExec.cpp b/src/commands/CmdExec.cpp index 7928c0e99..031671484 100644 --- a/src/commands/CmdExec.cpp +++ b/src/commands/CmdExec.cpp @@ -49,7 +49,15 @@ CmdExec::CmdExec () //////////////////////////////////////////////////////////////////////////////// int CmdExec::execute (std::string&) { - return system (join (" ", Context::getContext ().cli2.getWords ()).c_str ()); + std::string command = join (" ", Context::getContext ().cli2.getWords ()); + + if (command.empty()) + { + Context::getContext ().error ("Cannot execute an empty command."); + return 1; + } + else + return system (command.c_str ()); } ////////////////////////////////////////////////////////////////////////////////