mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-26 22:09:24 +01:00
fix a fairly bad bug where nicks could get out of sync
during nick change, removeInternal(client) was being called even before checking whether the new nick was in use or reserved. Reproduction steps: 1. Log in a client 'alice' 2. Log in a client 'bob' 3. bob issues /nick alice, which fails (correctly) with: :oragono.test 433 bob alice :Nickname is already in use 4. alice issues /msg bob hi, which fails (incorrectly) with: :oragono.test 401 alice bob :No such nick
This commit is contained in:
parent
9a2117f75d
commit
d0ded906d4
@ -129,7 +129,6 @@ func (clients *ClientManager) SetNick(client *Client, newNick string) error {
|
|||||||
clients.Lock()
|
clients.Lock()
|
||||||
defer clients.Unlock()
|
defer clients.Unlock()
|
||||||
|
|
||||||
clients.removeInternal(client)
|
|
||||||
currentNewEntry := clients.byNick[newcfnick]
|
currentNewEntry := clients.byNick[newcfnick]
|
||||||
// the client may just be changing case
|
// the client may just be changing case
|
||||||
if currentNewEntry != nil && currentNewEntry != client {
|
if currentNewEntry != nil && currentNewEntry != client {
|
||||||
@ -138,6 +137,7 @@ func (clients *ClientManager) SetNick(client *Client, newNick string) error {
|
|||||||
if method == NickReservationStrict && reservedAccount != client.Account() {
|
if method == NickReservationStrict && reservedAccount != client.Account() {
|
||||||
return errNicknameReserved
|
return errNicknameReserved
|
||||||
}
|
}
|
||||||
|
clients.removeInternal(client)
|
||||||
clients.byNick[newcfnick] = client
|
clients.byNick[newcfnick] = client
|
||||||
client.updateNickMask(newNick)
|
client.updateNickMask(newNick)
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user