3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-10 22:19:31 +01:00

move a check, avoiding a crash

This commit is contained in:
Shivaram Lingamneni 2017-10-23 18:01:28 -04:00
parent 240f121e5e
commit 71e82a9ccf

View File

@ -327,11 +327,7 @@ func (client *Client) applyUserModeChanges(force bool, changes ModeChanges) Mode
// MODE <target> [<modestring> [<mode arguments>...]]
func umodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
nickname, err := CasefoldName(msg.Params[0])
target := server.clients.Get(nickname)
targetNick := target.getNick()
hasPrivs := client == target || msg.Command == "SAMODE"
if err != nil || target == nil {
if len(msg.Params[0]) > 0 {
client.Send(nil, server.name, ERR_NOSUCHNICK, client.nick, msg.Params[0], "No such nick")
@ -339,6 +335,9 @@ func umodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
return false
}
targetNick := target.getNick()
hasPrivs := client == target || msg.Command == "SAMODE"
if !hasPrivs {
if len(msg.Params) > 1 {
client.Send(nil, server.name, ERR_USERSDONTMATCH, client.nick, "Can't change modes for other users")