aboutsummaryrefslogtreecommitdiff
path: root/client.go
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2021-07-27 19:25:43 -0700
committerJeff Halter <868228+jhalter@users.noreply.github.com>2021-07-27 19:25:43 -0700
commit71c56068adca18f76ebee86355f000a3e51d3127 (patch)
tree2ed17731c1720e86015fbc952d78029459e8200a /client.go
parent028d97e7f84f5b8f1e0c73ebd7790e40c5819856 (diff)
Fix crash on shxd servers
Diffstat (limited to 'client.go')
-rw-r--r--client.go19
1 files changed, 10 insertions, 9 deletions
diff --git a/client.go b/client.go
index b2b0766..940e6fe 100644
--- a/client.go
+++ b/client.go
@@ -754,15 +754,16 @@ func (c *Client) GetTransactions() error {
func handleClientGetUserNameList(c *Client, t *Transaction) (res []Transaction, err error) {
var users []User
for _, field := range t.Fields {
- u, _ := ReadUser(field.Data)
- //flagBitmap := big.NewInt(int64(binary.BigEndian.Uint16(u.Flags)))
- //if flagBitmap.Bit(userFlagAdmin) == 1 {
- // fmt.Fprintf(UserList, "[red::b]%s[-:-:-]\n", u.Name)
- //} else {
- // fmt.Fprintf(UserList, "%s\n", u.Name)
- //}
-
- users = append(users, *u)
+ // The Hotline protocol docs say that ClientGetUserNameList should only return fieldUsernameWithInfo (300)
+ // fields, but shxd sneaks in fieldChatSubject (115) so it's important to filter explicitly for the expected
+ // field type. Probably a good idea to do everywhere.
+ if bytes.Equal(field.ID, []byte{0x01, 0x2c}) {
+ u, err := ReadUser(field.Data)
+ if err != nil {
+ return res, err
+ }
+ users = append(users, *u)
+ }
}
c.UserList = users