From 073c84762b90275feb350eb760c10539a4d386e1 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Tue, 29 Aug 2023 10:38:04 +0100 Subject: [PATCH 1/2] Max 1b items please, because clearly this is the right solution --- state/device_data_table.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/state/device_data_table.go b/state/device_data_table.go index 6e44d688..a024304c 100644 --- a/state/device_data_table.go +++ b/state/device_data_table.go @@ -104,7 +104,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 } } From 008ffb81c136cb3d4c2dd1bab8ae5fb169a68dd5 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Tue, 29 Aug 2023 10:57:00 +0100 Subject: [PATCH 2/2] Also for the SELECT --- state/device_data_table.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/state/device_data_table.go b/state/device_data_table.go index a024304c..cd9fc34b 100644 --- a/state/device_data_table.go +++ b/state/device_data_table.go @@ -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