Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Bugfix: validate nicknames in server JOIN messages (Thanks Cauchy)
- Loading branch information
Showing
with
14 additions
and
2 deletions.
-
+14
−2
ircserver/server_commands.go
|
@@ -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 { |
|
@@ -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 |
|
|
|
|
|