Skip to content

Commit

Permalink
Merge pull request #276 from matrix-org/kegan/cbor-max-keys
Browse files Browse the repository at this point in the history
Increase the number of user IDs allowed in device list changes
  • Loading branch information
kegsay authored Aug 29, 2023
2 parents 3ce665d + 008ffb8 commit 195c52f
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions state/device_data_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,14 @@ func (t *DeviceDataTable) Select(userID, deviceID string, swap bool) (result *in
return err
}
// unmarshal to swap
if err = cbor.Unmarshal(row.Data, &result); err != nil {
opts := cbor.DecOptions{
MaxMapPairs: 1000000000, // 1 billion :(
}
decMode, err := opts.DecMode()
if err != nil {
return err
}
if err = decMode.Unmarshal(row.Data, &result); err != nil {
return err
}
result.UserID = userID
Expand Down Expand Up @@ -104,7 +111,14 @@ func (t *DeviceDataTable) Upsert(dd *internal.DeviceData) (err error) {
// unmarshal and combine
var tempDD internal.DeviceData
if len(row.Data) > 0 {
if err = cbor.Unmarshal(row.Data, &tempDD); err != nil {
opts := cbor.DecOptions{
MaxMapPairs: 1000000000, // 1 billion :(
}
decMode, err := opts.DecMode()
if err != nil {
return err
}
if err = decMode.Unmarshal(row.Data, &tempDD); err != nil {
return err
}
}
Expand Down

0 comments on commit 195c52f

Please sign in to comment.