3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-23 03:02:48 +01:00

Merge pull request #1253 from slingamn/registration_bugs

fix critical bugs in 2.3.0-rc1
This commit is contained in:
Shivaram Lingamneni 2020-08-29 21:21:39 -07:00 committed by GitHub
commit e05e624070
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -48,9 +48,8 @@ func (clients *ClientManager) Get(nick string) *Client {
return nil return nil
} }
func (clients *ClientManager) removeInternal(client *Client) (err error) { func (clients *ClientManager) removeInternal(client *Client, oldcfnick, oldskeleton string) (err error) {
// requires holding the writable Lock() // requires holding the writable Lock()
oldcfnick, oldskeleton := client.uniqueIdentifiers()
if oldcfnick == "*" || oldcfnick == "" { if oldcfnick == "*" || oldcfnick == "" {
return errNickMissing return errNickMissing
} }
@ -88,7 +87,8 @@ func (clients *ClientManager) Remove(client *Client) error {
clients.Lock() clients.Lock()
defer clients.Unlock() defer clients.Unlock()
return clients.removeInternal(client) oldcfnick, oldskeleton := client.uniqueIdentifiers()
return clients.removeInternal(client, oldcfnick, oldskeleton)
} }
// Handles a RESUME by attaching a session to a designated client. It is the // Handles a RESUME by attaching a session to a designated client. It is the
@ -240,10 +240,11 @@ func (clients *ClientManager) SetNick(client *Client, session *Session, newNick
return "", errNicknameInUse, false return "", errNicknameInUse, false
} }
formercfnick, formerskeleton := client.uniqueIdentifiers()
if changeSuccess := client.SetNick(newNick, newCfNick, newSkeleton); !changeSuccess { if changeSuccess := client.SetNick(newNick, newCfNick, newSkeleton); !changeSuccess {
return "", errClientDestroyed, false return "", errClientDestroyed, false
} }
clients.removeInternal(client) clients.removeInternal(client, formercfnick, formerskeleton)
clients.byNick[newCfNick] = client clients.byNick[newCfNick] = client
clients.bySkeleton[newSkeleton] = client clients.bySkeleton[newSkeleton] = client
return newNick, nil, false return newNick, nil, false

View File

@ -129,7 +129,8 @@ func fixupNickEqualsAccount(client *Client, rb *ResponseBuffer, config *Config)
if !client.registered { if !client.registered {
return true return true
} }
if performNickChange(client.server, client, client, rb.session, client.AccountName(), rb) != nil { err := performNickChange(client.server, client, client, rb.session, client.AccountName(), rb)
if err != nil && err != errNoop {
client.server.accounts.Logout(client) client.server.accounts.Logout(client)
nsNotice(rb, client.t("A client is already using that account; try logging out and logging back in with SASL")) nsNotice(rb, client.t("A client is already using that account; try logging out and logging back in with SASL"))
return false return false