Skip to content

Commit bc40477

Browse files
committed
server.DeleteMessage catches channel or client==nil
Fixes #2020 Calling /msg histserv delete #wrongchan <msgid> returns spurrious success message. Calling /msg histserv delete <randomchars> <msgid> returns similar message. These would lead to the pointer hist == nil, and server.historyDB.DeleteMsgid() would return nil. Returns errNoSuchChannel or errInvalidTarget if channel or client == nil
1 parent f6f7315 commit bc40477

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

irc/errors.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ var (
5454
errConfusableIdentifier = errors.New("This identifier is confusable with one already in use")
5555
errInsufficientPrivs = errors.New("Insufficient privileges")
5656
errInvalidUsername = errors.New("Invalid username")
57+
errInvalidTarget = errors.New("Invalid target")
5758
errFeatureDisabled = errors.New(`That feature is disabled`)
5859
errBanned = errors.New("IP or nickmask banned")
5960
errInvalidParams = utils.ErrInvalidParams

irc/server.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,13 +1061,17 @@ func (server *Server) DeleteMessage(target, msgid, accountName string) (err erro
10611061
if status, _, _ := channel.historyStatus(config); status == HistoryEphemeral {
10621062
hist = &channel.history
10631063
}
1064+
} else {
1065+
return errNoSuchChannel
10641066
}
10651067
} else {
10661068
client := server.clients.Get(target)
10671069
if client != nil {
10681070
if status, _ := client.historyStatus(config); status == HistoryEphemeral {
10691071
hist = &client.history
10701072
}
1073+
} else {
1074+
return errInvalidTarget
10711075
}
10721076
}
10731077
}

0 commit comments

Comments
 (0)