3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-10 22:19:31 +01:00

Only allow valid snomasks to be set

This commit is contained in:
Daniel Oaks 2018-04-16 13:20:37 +10:00
parent 22f9df388d
commit 5811226760
3 changed files with 26 additions and 1 deletions

View File

@ -54,10 +54,16 @@ func (client *Client) applyUserModeChanges(force bool, changes modes.ModeChanges
} }
var masks []sno.Mask var masks []sno.Mask
if change.Op == modes.Add || change.Op == modes.Remove { if change.Op == modes.Add || change.Op == modes.Remove {
var newArg string
for _, char := range change.Arg { for _, char := range change.Arg {
masks = append(masks, sno.Mask(char)) mask := sno.Mask(char)
if sno.ValidMasks[mask] {
masks = append(masks, mask)
newArg += string(char)
} }
} }
change.Arg = newArg
}
if change.Op == modes.Add { if change.Op == modes.Add {
client.server.snomasks.AddMasks(client, masks...) client.server.snomasks.AddMasks(client, masks...)
applied = append(applied, change) applied = append(applied, change)

View File

@ -35,4 +35,18 @@ var (
LocalAccounts: "ACCOUNT", LocalAccounts: "ACCOUNT",
LocalXline: "XLINE", LocalXline: "XLINE",
} }
// ValidMasks contains the snomasks that we support.
ValidMasks = map[Mask]bool{
LocalAccouncements: true,
LocalConnects: true,
LocalChannels: true,
LocalKills: true,
LocalNicks: true,
LocalOpers: true,
LocalQuits: true,
Stats: true,
LocalAccounts: true,
LocalXline: true,
}
) )

View File

@ -27,6 +27,11 @@ func (m *SnoManager) AddMasks(client *Client, masks ...sno.Mask) {
defer m.sendListMutex.Unlock() defer m.sendListMutex.Unlock()
for _, mask := range masks { for _, mask := range masks {
// confirm mask is valid
if !sno.ValidMasks[mask] {
continue
}
currentClientList := m.sendLists[mask] currentClientList := m.sendLists[mask]
if currentClientList == nil { if currentClientList == nil {