summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2017-06-22 16:32:50 +0000
committerfrosch <frosch@openttd.org>2017-06-22 16:32:50 +0000
commit80d10598c1cc4e071651f7d3c3611bed5156ef2f (patch)
treebd481587a930ee0640db347aba84ef75e3b60126
parentbb02505fb3a4ddf403871cd2010c4517dc32c516 (diff)
downloadopenttd-80d10598c1cc4e071651f7d3c3611bed5156ef2f.tar.xz
(svn r27884) -Fix: Console command parser failed when the command had many parameters, and also did not print any error messages about it.
-rw-r--r--src/console.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/console.cpp b/src/console.cpp
index ef62a8f28..ece859916 100644
--- a/src/console.cpp
+++ b/src/console.cpp
@@ -434,7 +434,10 @@ void IConsoleCmdExec(const char *cmdstr)
* enclosed in "" are taken as one token. We can only go as far as the amount
* of characters in our stream or the max amount of tokens we can handle */
for (cmdptr = cmdstr, t_index = 0, tstream_i = 0; *cmdptr != '\0'; cmdptr++) {
- if (t_index >= lengthof(tokens) || tstream_i >= lengthof(tokenstream)) break;
+ if (tstream_i >= lengthof(tokenstream)) {
+ IConsoleError("command line too long");
+ return;
+ }
switch (*cmdptr) {
case ' ': // Token separator
@@ -452,6 +455,10 @@ void IConsoleCmdExec(const char *cmdstr)
case '"': // Tokens enclosed in "" are one token
longtoken = !longtoken;
if (!foundtoken) {
+ if (t_index >= lengthof(tokens)) {
+ IConsoleError("command line too long");
+ return;
+ }
tokens[t_index++] = &tokenstream[tstream_i];
foundtoken = true;
}
@@ -466,6 +473,10 @@ void IConsoleCmdExec(const char *cmdstr)
tokenstream[tstream_i++] = *cmdptr;
if (!foundtoken) {
+ if (t_index >= lengthof(tokens)) {
+ IConsoleError("command line too long");
+ return;
+ }
tokens[t_index++] = &tokenstream[tstream_i - 1];
foundtoken = true;
}