Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bugfix: validate nicknames in server JOIN messages (Thanks Cauchy)
  • Loading branch information
stapelberg committed Dec 16, 2015
1 parent a6a8b97 commit 979b014
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions ircserver/server_commands.go
Expand Up @@ -641,6 +641,18 @@ func (i *IRCServer) cmdServerJoin(s *Session, reply *Replyctx, msg *irc.Message)
})
continue
}

nick := NickToLower(msg.Prefix.Name)
if _, ok := i.nicks[nick]; !ok {
i.sendServices(reply, &irc.Message{
Prefix: i.ServerPrefix,
Command: irc.ERR_NOSUCHNICK,
Params: []string{msg.Prefix.Name, channelname},
Trailing: "No such nick/channel",
})
continue
}

// TODO(secure): reduce code duplication with cmdJoin()
c, ok := i.channels[ChanToLower(channelname)]
if !ok {
Expand All @@ -650,11 +662,11 @@ func (i *IRCServer) cmdServerJoin(s *Session, reply *Replyctx, msg *irc.Message)
}
i.channels[ChanToLower(channelname)] = c
}
c.nicks[NickToLower(msg.Prefix.Name)] = &[maxChanMemberStatus]bool{}
c.nicks[nick] = &[maxChanMemberStatus]bool{}
// If the channel did not exist before, the first joining user becomes a
// channel operator.
if !ok {
c.nicks[NickToLower(msg.Prefix.Name)][chanop] = true
c.nicks[nick][chanop] = true
}
s.Channels[ChanToLower(channelname)] = true

Expand Down

0 comments on commit 979b014

Please sign in to comment.