CTCP Messages must be more then 2 characters long.

Avoid panic on malformed CTCP messages.
This commit is contained in:
Thomas Jager 2015-03-31 15:14:13 +02:00
parent 47e552f62d
commit 087ae892d0

View File

@ -77,7 +77,7 @@ func (irc *Connection) ReplaceCallback(eventcode string, i string, callback func
// Execute all callbacks associated with a given event. // Execute all callbacks associated with a given event.
func (irc *Connection) RunCallbacks(event *Event) { func (irc *Connection) RunCallbacks(event *Event) {
msg := event.Message() msg := event.Message()
if event.Code == "PRIVMSG" && len(msg) > 0 && msg[0] == '\x01' { if event.Code == "PRIVMSG" && len(msg) > 2 && msg[0] == '\x01' {
event.Code = "CTCP" //Unknown CTCP event.Code = "CTCP" //Unknown CTCP
if i := strings.LastIndex(msg, "\x01"); i > -1 { if i := strings.LastIndex(msg, "\x01"); i > -1 {