3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-23 04:19:25 +01:00

Merge pull request #291 from slingamn/samode_crash

fix a crash when SAMODE'ing in a channel you're not joined to
This commit is contained in:
Daniel Oaks 2018-08-20 16:48:05 +10:00 committed by GitHub
commit 508c3269a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -239,9 +239,12 @@ func (channel *Channel) Names(client *Client, rb *ResponseBuffer) {
// ClientIsAtLeast returns whether the client has at least the given channel privilege.
func (channel *Channel) ClientIsAtLeast(client *Client, permission modes.Mode) bool {
channel.stateMutex.RLock()
defer channel.stateMutex.RUnlock()
clientModes := channel.members[client]
channel.stateMutex.RUnlock()
if clientModes == nil {
return false
}
for _, mode := range modes.ChannelUserModes {
if clientModes.HasMode(mode) {

View File

@ -108,7 +108,6 @@ func (channel *Channel) ApplyChannelModeChanges(client *Client, isSamode bool, c
// so we only output one warning for each list type when full
listFullWarned := make(map[modes.Mode]bool)
clientIsOp := channel.ClientIsAtLeast(client, modes.ChannelOperator)
var alreadySentPrivError bool
applied := make(modes.ModeChanges, 0)
@ -141,9 +140,9 @@ func (channel *Channel) ApplyChannelModeChanges(client *Client, isSamode bool, c
return channel.ClientIsAtLeast(client, change.Mode)
case modes.BanMask:
// #163: allow unprivileged users to list ban masks
return clientIsOp || isListOp(change)
return isListOp(change) || channel.ClientIsAtLeast(client, modes.ChannelOperator)
default:
return clientIsOp
return channel.ClientIsAtLeast(client, modes.ChannelOperator)
}
}