Fix buffer overrun in command token process function