Skip to content

Commit

Permalink
server.DeleteMessage catches channel or client==nil
Browse files Browse the repository at this point in the history
Fixes ergochat#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
  • Loading branch information
FiskFan1999 committed Dec 25, 2022
1 parent f6f7315 commit bc40477
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions irc/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ var (
errConfusableIdentifier = errors.New("This identifier is confusable with one already in use")
errInsufficientPrivs = errors.New("Insufficient privileges")
errInvalidUsername = errors.New("Invalid username")
errInvalidTarget = errors.New("Invalid target")
errFeatureDisabled = errors.New(`That feature is disabled`)
errBanned = errors.New("IP or nickmask banned")
errInvalidParams = utils.ErrInvalidParams
Expand Down
4 changes: 4 additions & 0 deletions irc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1061,13 +1061,17 @@ func (server *Server) DeleteMessage(target, msgid, accountName string) (err erro
if status, _, _ := channel.historyStatus(config); status == HistoryEphemeral {
hist = &channel.history
}
} else {
return errNoSuchChannel
}
} else {
client := server.clients.Get(target)
if client != nil {
if status, _ := client.historyStatus(config); status == HistoryEphemeral {
hist = &client.history
}
} else {
return errInvalidTarget
}
}
}
Expand Down

0 comments on commit bc40477

Please sign in to comment.