diff options
| author | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2022-06-24 19:23:44 -0700 |
|---|---|---|
| committer | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2022-06-24 19:23:44 -0700 |
| commit | 264b7c27c7a46e2d0eb699812c8e38cf771fcf00 (patch) | |
| tree | dafb05e80e882f5671ea35d4d11a62e9f1518de3 /hotline/transaction_handlers.go | |
| parent | a7216f677e7b02831328293224730f6f06f2d38a (diff) | |
Prevent user with accessAnyName from change name
Diffstat (limited to 'hotline/transaction_handlers.go')
| -rw-r--r-- | hotline/transaction_handlers.go | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/hotline/transaction_handlers.go b/hotline/transaction_handlers.go index aa994b9..2a81768 100644 --- a/hotline/transaction_handlers.go +++ b/hotline/transaction_handlers.go @@ -1593,18 +1593,17 @@ func HandleUploadFile(cc *ClientConn, t *Transaction) (res []Transaction, err er } func HandleSetClientUserInfo(cc *ClientConn, t *Transaction) (res []Transaction, err error) { - var icon []byte if len(t.GetField(fieldUserIconID).Data) == 4 { - icon = t.GetField(fieldUserIconID).Data[2:] + cc.Icon = t.GetField(fieldUserIconID).Data[2:] } else { - icon = t.GetField(fieldUserIconID).Data + cc.Icon = t.GetField(fieldUserIconID).Data + } + if cc.Authorize(accessAnyName) { + cc.UserName = t.GetField(fieldUserName).Data } - cc.Icon = icon - cc.UserName = t.GetField(fieldUserName).Data // the options field is only passed by the client versions > 1.2.3. options := t.GetField(fieldOptions).Data - if options != nil { optBitmap := big.NewInt(int64(binary.BigEndian.Uint16(options))) flagBitmap := big.NewInt(int64(binary.BigEndian.Uint16(cc.Flags))) @@ -1623,14 +1622,16 @@ func HandleSetClientUserInfo(cc *ClientConn, t *Transaction) (res []Transaction, } } - // Notify all clients of updated user info - cc.sendAll( - tranNotifyChangeUser, - NewField(fieldUserID, *cc.ID), - NewField(fieldUserIconID, cc.Icon), - NewField(fieldUserFlags, cc.Flags), - NewField(fieldUserName, cc.UserName), - ) + for _, c := range sortedClients(cc.Server.Clients) { + res = append(res, *NewTransaction( + tranNotifyChangeUser, + c.ID, + NewField(fieldUserID, *cc.ID), + NewField(fieldUserIconID, cc.Icon), + NewField(fieldUserFlags, cc.Flags), + NewField(fieldUserName, cc.UserName), + )) + } return res, err } |