1

Closed

Command Parameter Count Check

description

Hi,
 
In some commands the checks for command parameters are not strict enough. For example
 
/time
 
crashes with an index out of range.
 
I think best would be to define the number (and type) of parameters as part of the command interface (if you do not allow a variable amout of parameters). Or just the min and max number of parameters for easier and more uniform checks.
 
Anyway in the case of time the code should read:
 
    public override void ExecuteCommand(RemoteClient client, params string[] parameters)
    {
        if (parameters.Length < 1 || parameters.Length > 2)
        {
            client.PacketQueue.Enqueue(new ChatMessagePacket("§4Invalid parameters. /help time for usage."));
            return;
        }
       ....
 
wvd_vegt
Closed Mar 3, 2012 at 10:20 PM by sircmpwn
Commands have been changed to individually validate their parameters.

comments