From bc40477b2e13f4c9ca0bdeb9cdf544eadfc92512 Mon Sep 17 00:00:00 2001 From: William Rehwinkel Date: Sun, 25 Dec 2022 12:23:39 -0500 Subject: [PATCH] server.DeleteMessage catches channel or client==nil Fixes #2020 Calling /msg histserv delete #wrongchan returns spurrious success message. Calling /msg histserv delete 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 --- irc/errors.go | 1 + irc/server.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/irc/errors.go b/irc/errors.go index 34f7fcdbc..1f0d09f29 100644 --- a/irc/errors.go +++ b/irc/errors.go @@ -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 diff --git a/irc/server.go b/irc/server.go index 1a7e1abd4..4d4b3677a 100644 --- a/irc/server.go +++ b/irc/server.go @@ -1061,6 +1061,8 @@ 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) @@ -1068,6 +1070,8 @@ func (server *Server) DeleteMessage(target, msgid, accountName string) (err erro if status, _ := client.historyStatus(config); status == HistoryEphemeral { hist = &client.history } + } else { + return errInvalidTarget } } }