Skip to content

Commit

Permalink
Bugfix: verify inviter is on the channel
Browse files Browse the repository at this point in the history
This bug results in a crash and contributed to the trouble
described in issue #115.
  • Loading branch information
stapelberg committed Apr 30, 2015
1 parent b43e73c commit 49cc2e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ircserver/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -1522,6 +1522,13 @@ func (i *IRCServer) cmdInvite(s *Session, msg *irc.Message) []*irc.Message {
Trailing: "You're not on that channel",
}}
}
if _, ok := c.nicks[NickToLower(s.Nick)]; !ok {
return []*irc.Message{{
Command: irc.ERR_NOTONCHANNEL,
Params: []string{s.Nick, msg.Params[1]},
Trailing: "You're not on that channel",
}}
}
session, ok := i.nicks[NickToLower(nickname)]
if !ok {
return []*irc.Message{{
Expand Down
4 changes: 4 additions & 0 deletions ircserver/ircserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,10 @@ func TestInvite(t *testing.T) {
irc.ParseMessage(":robustirc.net 366 sECuRE #test :End of /NAMES list."),
})

mustMatchMsg(t,
i.ProcessMessage(ids["mero"], irc.ParseMessage("INVITE mero #test")),
":robustirc.net 442 mero #test :You're not on that channel")

mustMatchIrcmsgs(t,
i.ProcessMessage(ids["secure"], irc.ParseMessage("INVITE mero #test")),
[]*irc.Message{
Expand Down

0 comments on commit 49cc2e0

Please sign in to comment.