chat commands: check message length before use

If we don't check the length of the message before we access it with substring(command.length() + 1) we will get a string index out of range error.

Co-authored-by: Paul Wendelboe <pwendelboe.git@gmail.com>
This commit is contained in:
Adam
2019-03-12 08:29:16 -04:00
parent 984a9a30c4
commit 0562e9e49e

View File

@@ -366,6 +366,11 @@ public class ChatCommandsPlugin extends Plugin
return;
}
if (message.length() <= KILLCOUNT_COMMAND_STRING.length())
{
return;
}
ChatMessageType type = chatMessage.getType();
String search = message.substring(KILLCOUNT_COMMAND_STRING.length() + 1);
@@ -483,6 +488,11 @@ public class ChatCommandsPlugin extends Plugin
return;
}
if (message.length() <= PB_COMMAND.length())
{
return;
}
ChatMessageType type = chatMessage.getType();
String search = message.substring(PB_COMMAND.length() + 1);
@@ -574,6 +584,11 @@ public class ChatCommandsPlugin extends Plugin
return;
}
if (message.length() <= PRICE_COMMAND_STRING.length())
{
return;
}
MessageNode messageNode = chatMessage.getMessageNode();
String search = message.substring(PRICE_COMMAND_STRING.length() + 1);
@@ -637,6 +652,11 @@ public class ChatCommandsPlugin extends Plugin
}
else
{
if (message.length() <= LEVEL_COMMAND_STRING.length())
{
return;
}
search = message.substring(LEVEL_COMMAND_STRING.length() + 1);
}