diff --git a/api/atproto/cbor_gen.go b/api/atproto/cbor_gen.go index 870eba4f..9fbc2d90 100644 --- a/api/atproto/cbor_gen.go +++ b/api/atproto/cbor_gen.go @@ -37,7 +37,7 @@ func (t *RepoStrongRef) MarshalCBOR(w io.Writer) error { } // t.Cid (string) (string) - if uint64(len("cid")) > cbg.MaxLength { + if len("cid") > 1000000 { return xerrors.Errorf("Value in field \"cid\" was too long") } @@ -48,7 +48,7 @@ func (t *RepoStrongRef) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Cid)) > cbg.MaxLength { + if len(t.Cid) > 1000000 { return xerrors.Errorf("Value in field t.Cid was too long") } @@ -60,7 +60,7 @@ func (t *RepoStrongRef) MarshalCBOR(w io.Writer) error { } // t.Uri (string) (string) - if uint64(len("uri")) > cbg.MaxLength { + if len("uri") > 1000000 { return xerrors.Errorf("Value in field \"uri\" was too long") } @@ -71,7 +71,7 @@ func (t *RepoStrongRef) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Uri)) > cbg.MaxLength { + if len(t.Uri) > 1000000 { return xerrors.Errorf("Value in field t.Uri was too long") } @@ -85,7 +85,7 @@ func (t *RepoStrongRef) MarshalCBOR(w io.Writer) error { // t.LexiconTypeID (string) (string) if t.LexiconTypeID != "" { - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -135,7 +135,7 @@ func (t *RepoStrongRef) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -148,7 +148,7 @@ func (t *RepoStrongRef) UnmarshalCBOR(r io.Reader) (err error) { case "cid": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -159,7 +159,7 @@ func (t *RepoStrongRef) UnmarshalCBOR(r io.Reader) (err error) { case "uri": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -170,7 +170,7 @@ func (t *RepoStrongRef) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -204,7 +204,7 @@ func (t *SyncSubscribeRepos_Commit) MarshalCBOR(w io.Writer) error { } // t.Ops ([]*atproto.SyncSubscribeRepos_RepoOp) (slice) - if uint64(len("ops")) > cbg.MaxLength { + if len("ops") > 1000000 { return xerrors.Errorf("Value in field \"ops\" was too long") } @@ -215,7 +215,7 @@ func (t *SyncSubscribeRepos_Commit) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Ops)) > cbg.MaxLength { + if len(t.Ops) > 8192 { return xerrors.Errorf("Slice value in field t.Ops was too long") } @@ -230,7 +230,7 @@ func (t *SyncSubscribeRepos_Commit) MarshalCBOR(w io.Writer) error { } // t.Rev (string) (string) - if uint64(len("rev")) > cbg.MaxLength { + if len("rev") > 1000000 { return xerrors.Errorf("Value in field \"rev\" was too long") } @@ -241,7 +241,7 @@ func (t *SyncSubscribeRepos_Commit) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Rev)) > cbg.MaxLength { + if len(t.Rev) > 1000000 { return xerrors.Errorf("Value in field t.Rev was too long") } @@ -253,7 +253,7 @@ func (t *SyncSubscribeRepos_Commit) MarshalCBOR(w io.Writer) error { } // t.Seq (int64) (int64) - if uint64(len("seq")) > cbg.MaxLength { + if len("seq") > 1000000 { return xerrors.Errorf("Value in field \"seq\" was too long") } @@ -275,7 +275,7 @@ func (t *SyncSubscribeRepos_Commit) MarshalCBOR(w io.Writer) error { } // t.Prev (util.LexLink) (struct) - if uint64(len("prev")) > cbg.MaxLength { + if len("prev") > 1000000 { return xerrors.Errorf("Value in field \"prev\" was too long") } @@ -291,7 +291,7 @@ func (t *SyncSubscribeRepos_Commit) MarshalCBOR(w io.Writer) error { } // t.Repo (string) (string) - if uint64(len("repo")) > cbg.MaxLength { + if len("repo") > 1000000 { return xerrors.Errorf("Value in field \"repo\" was too long") } @@ -302,7 +302,7 @@ func (t *SyncSubscribeRepos_Commit) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Repo)) > cbg.MaxLength { + if len(t.Repo) > 1000000 { return xerrors.Errorf("Value in field t.Repo was too long") } @@ -314,7 +314,7 @@ func (t *SyncSubscribeRepos_Commit) MarshalCBOR(w io.Writer) error { } // t.Time (string) (string) - if uint64(len("time")) > cbg.MaxLength { + if len("time") > 1000000 { return xerrors.Errorf("Value in field \"time\" was too long") } @@ -325,7 +325,7 @@ func (t *SyncSubscribeRepos_Commit) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Time)) > cbg.MaxLength { + if len(t.Time) > 1000000 { return xerrors.Errorf("Value in field t.Time was too long") } @@ -337,7 +337,7 @@ func (t *SyncSubscribeRepos_Commit) MarshalCBOR(w io.Writer) error { } // t.Blobs ([]util.LexLink) (slice) - if uint64(len("blobs")) > cbg.MaxLength { + if len("blobs") > 1000000 { return xerrors.Errorf("Value in field \"blobs\" was too long") } @@ -348,7 +348,7 @@ func (t *SyncSubscribeRepos_Commit) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Blobs)) > cbg.MaxLength { + if len(t.Blobs) > 8192 { return xerrors.Errorf("Slice value in field t.Blobs was too long") } @@ -363,7 +363,7 @@ func (t *SyncSubscribeRepos_Commit) MarshalCBOR(w io.Writer) error { } // t.Since (string) (string) - if uint64(len("since")) > cbg.MaxLength { + if len("since") > 1000000 { return xerrors.Errorf("Value in field \"since\" was too long") } @@ -379,7 +379,7 @@ func (t *SyncSubscribeRepos_Commit) MarshalCBOR(w io.Writer) error { return err } } else { - if uint64(len(*t.Since)) > cbg.MaxLength { + if len(*t.Since) > 1000000 { return xerrors.Errorf("Value in field t.Since was too long") } @@ -394,7 +394,7 @@ func (t *SyncSubscribeRepos_Commit) MarshalCBOR(w io.Writer) error { // t.Blocks (util.LexBytes) (slice) if t.Blocks != nil { - if uint64(len("blocks")) > cbg.MaxLength { + if len("blocks") > 1000000 { return xerrors.Errorf("Value in field \"blocks\" was too long") } @@ -405,7 +405,7 @@ func (t *SyncSubscribeRepos_Commit) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Blocks)) > cbg.ByteArrayMaxLen { + if len(t.Blocks) > 2097152 { return xerrors.Errorf("Byte array in field t.Blocks was too long") } @@ -420,7 +420,7 @@ func (t *SyncSubscribeRepos_Commit) MarshalCBOR(w io.Writer) error { } // t.Commit (util.LexLink) (struct) - if uint64(len("commit")) > cbg.MaxLength { + if len("commit") > 1000000 { return xerrors.Errorf("Value in field \"commit\" was too long") } @@ -436,7 +436,7 @@ func (t *SyncSubscribeRepos_Commit) MarshalCBOR(w io.Writer) error { } // t.Rebase (bool) (bool) - if uint64(len("rebase")) > cbg.MaxLength { + if len("rebase") > 1000000 { return xerrors.Errorf("Value in field \"rebase\" was too long") } @@ -452,7 +452,7 @@ func (t *SyncSubscribeRepos_Commit) MarshalCBOR(w io.Writer) error { } // t.TooBig (bool) (bool) - if uint64(len("tooBig")) > cbg.MaxLength { + if len("tooBig") > 1000000 { return xerrors.Errorf("Value in field \"tooBig\" was too long") } @@ -498,7 +498,7 @@ func (t *SyncSubscribeRepos_Commit) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -515,7 +515,7 @@ func (t *SyncSubscribeRepos_Commit) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.Ops: array too large (%d)", extra) } @@ -560,7 +560,7 @@ func (t *SyncSubscribeRepos_Commit) UnmarshalCBOR(r io.Reader) (err error) { case "rev": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -571,10 +571,10 @@ func (t *SyncSubscribeRepos_Commit) UnmarshalCBOR(r io.Reader) (err error) { case "seq": { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -617,7 +617,7 @@ func (t *SyncSubscribeRepos_Commit) UnmarshalCBOR(r io.Reader) (err error) { case "repo": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -628,7 +628,7 @@ func (t *SyncSubscribeRepos_Commit) UnmarshalCBOR(r io.Reader) (err error) { case "time": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -643,7 +643,7 @@ func (t *SyncSubscribeRepos_Commit) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.Blobs: array too large (%d)", extra) } @@ -687,7 +687,7 @@ func (t *SyncSubscribeRepos_Commit) UnmarshalCBOR(r io.Reader) (err error) { return err } - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -703,7 +703,7 @@ func (t *SyncSubscribeRepos_Commit) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.ByteArrayMaxLen { + if extra > 2097152 { return fmt.Errorf("t.Blocks: byte array too large (%d)", extra) } if maj != cbg.MajByteString { @@ -786,7 +786,7 @@ func (t *SyncSubscribeRepos_Handle) MarshalCBOR(w io.Writer) error { } // t.Did (string) (string) - if uint64(len("did")) > cbg.MaxLength { + if len("did") > 1000000 { return xerrors.Errorf("Value in field \"did\" was too long") } @@ -797,7 +797,7 @@ func (t *SyncSubscribeRepos_Handle) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Did)) > cbg.MaxLength { + if len(t.Did) > 1000000 { return xerrors.Errorf("Value in field t.Did was too long") } @@ -809,7 +809,7 @@ func (t *SyncSubscribeRepos_Handle) MarshalCBOR(w io.Writer) error { } // t.Seq (int64) (int64) - if uint64(len("seq")) > cbg.MaxLength { + if len("seq") > 1000000 { return xerrors.Errorf("Value in field \"seq\" was too long") } @@ -831,7 +831,7 @@ func (t *SyncSubscribeRepos_Handle) MarshalCBOR(w io.Writer) error { } // t.Time (string) (string) - if uint64(len("time")) > cbg.MaxLength { + if len("time") > 1000000 { return xerrors.Errorf("Value in field \"time\" was too long") } @@ -842,7 +842,7 @@ func (t *SyncSubscribeRepos_Handle) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Time)) > cbg.MaxLength { + if len(t.Time) > 1000000 { return xerrors.Errorf("Value in field t.Time was too long") } @@ -854,7 +854,7 @@ func (t *SyncSubscribeRepos_Handle) MarshalCBOR(w io.Writer) error { } // t.Handle (string) (string) - if uint64(len("handle")) > cbg.MaxLength { + if len("handle") > 1000000 { return xerrors.Errorf("Value in field \"handle\" was too long") } @@ -865,7 +865,7 @@ func (t *SyncSubscribeRepos_Handle) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Handle)) > cbg.MaxLength { + if len(t.Handle) > 1000000 { return xerrors.Errorf("Value in field t.Handle was too long") } @@ -907,7 +907,7 @@ func (t *SyncSubscribeRepos_Handle) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -920,7 +920,7 @@ func (t *SyncSubscribeRepos_Handle) UnmarshalCBOR(r io.Reader) (err error) { case "did": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -931,10 +931,10 @@ func (t *SyncSubscribeRepos_Handle) UnmarshalCBOR(r io.Reader) (err error) { case "seq": { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -957,7 +957,7 @@ func (t *SyncSubscribeRepos_Handle) UnmarshalCBOR(r io.Reader) (err error) { case "time": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -968,7 +968,7 @@ func (t *SyncSubscribeRepos_Handle) UnmarshalCBOR(r io.Reader) (err error) { case "handle": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -997,7 +997,7 @@ func (t *SyncSubscribeRepos_Identity) MarshalCBOR(w io.Writer) error { } // t.Did (string) (string) - if uint64(len("did")) > cbg.MaxLength { + if len("did") > 1000000 { return xerrors.Errorf("Value in field \"did\" was too long") } @@ -1008,7 +1008,7 @@ func (t *SyncSubscribeRepos_Identity) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Did)) > cbg.MaxLength { + if len(t.Did) > 1000000 { return xerrors.Errorf("Value in field t.Did was too long") } @@ -1020,7 +1020,7 @@ func (t *SyncSubscribeRepos_Identity) MarshalCBOR(w io.Writer) error { } // t.Seq (int64) (int64) - if uint64(len("seq")) > cbg.MaxLength { + if len("seq") > 1000000 { return xerrors.Errorf("Value in field \"seq\" was too long") } @@ -1042,7 +1042,7 @@ func (t *SyncSubscribeRepos_Identity) MarshalCBOR(w io.Writer) error { } // t.Time (string) (string) - if uint64(len("time")) > cbg.MaxLength { + if len("time") > 1000000 { return xerrors.Errorf("Value in field \"time\" was too long") } @@ -1053,7 +1053,7 @@ func (t *SyncSubscribeRepos_Identity) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Time)) > cbg.MaxLength { + if len(t.Time) > 1000000 { return xerrors.Errorf("Value in field t.Time was too long") } @@ -1095,7 +1095,7 @@ func (t *SyncSubscribeRepos_Identity) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1108,7 +1108,7 @@ func (t *SyncSubscribeRepos_Identity) UnmarshalCBOR(r io.Reader) (err error) { case "did": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1119,10 +1119,10 @@ func (t *SyncSubscribeRepos_Identity) UnmarshalCBOR(r io.Reader) (err error) { case "seq": { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -1145,7 +1145,7 @@ func (t *SyncSubscribeRepos_Identity) UnmarshalCBOR(r io.Reader) (err error) { case "time": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1179,7 +1179,7 @@ func (t *SyncSubscribeRepos_Info) MarshalCBOR(w io.Writer) error { } // t.Name (string) (string) - if uint64(len("name")) > cbg.MaxLength { + if len("name") > 1000000 { return xerrors.Errorf("Value in field \"name\" was too long") } @@ -1190,7 +1190,7 @@ func (t *SyncSubscribeRepos_Info) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Name)) > cbg.MaxLength { + if len(t.Name) > 1000000 { return xerrors.Errorf("Value in field t.Name was too long") } @@ -1204,7 +1204,7 @@ func (t *SyncSubscribeRepos_Info) MarshalCBOR(w io.Writer) error { // t.Message (string) (string) if t.Message != nil { - if uint64(len("message")) > cbg.MaxLength { + if len("message") > 1000000 { return xerrors.Errorf("Value in field \"message\" was too long") } @@ -1220,7 +1220,7 @@ func (t *SyncSubscribeRepos_Info) MarshalCBOR(w io.Writer) error { return err } } else { - if uint64(len(*t.Message)) > cbg.MaxLength { + if len(*t.Message) > 1000000 { return xerrors.Errorf("Value in field t.Message was too long") } @@ -1264,7 +1264,7 @@ func (t *SyncSubscribeRepos_Info) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1277,7 +1277,7 @@ func (t *SyncSubscribeRepos_Info) UnmarshalCBOR(r io.Reader) (err error) { case "name": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1297,7 +1297,7 @@ func (t *SyncSubscribeRepos_Info) UnmarshalCBOR(r io.Reader) (err error) { return err } - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1327,7 +1327,7 @@ func (t *SyncSubscribeRepos_Migrate) MarshalCBOR(w io.Writer) error { } // t.Did (string) (string) - if uint64(len("did")) > cbg.MaxLength { + if len("did") > 1000000 { return xerrors.Errorf("Value in field \"did\" was too long") } @@ -1338,7 +1338,7 @@ func (t *SyncSubscribeRepos_Migrate) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Did)) > cbg.MaxLength { + if len(t.Did) > 1000000 { return xerrors.Errorf("Value in field t.Did was too long") } @@ -1350,7 +1350,7 @@ func (t *SyncSubscribeRepos_Migrate) MarshalCBOR(w io.Writer) error { } // t.Seq (int64) (int64) - if uint64(len("seq")) > cbg.MaxLength { + if len("seq") > 1000000 { return xerrors.Errorf("Value in field \"seq\" was too long") } @@ -1372,7 +1372,7 @@ func (t *SyncSubscribeRepos_Migrate) MarshalCBOR(w io.Writer) error { } // t.Time (string) (string) - if uint64(len("time")) > cbg.MaxLength { + if len("time") > 1000000 { return xerrors.Errorf("Value in field \"time\" was too long") } @@ -1383,7 +1383,7 @@ func (t *SyncSubscribeRepos_Migrate) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Time)) > cbg.MaxLength { + if len(t.Time) > 1000000 { return xerrors.Errorf("Value in field t.Time was too long") } @@ -1395,7 +1395,7 @@ func (t *SyncSubscribeRepos_Migrate) MarshalCBOR(w io.Writer) error { } // t.MigrateTo (string) (string) - if uint64(len("migrateTo")) > cbg.MaxLength { + if len("migrateTo") > 1000000 { return xerrors.Errorf("Value in field \"migrateTo\" was too long") } @@ -1411,7 +1411,7 @@ func (t *SyncSubscribeRepos_Migrate) MarshalCBOR(w io.Writer) error { return err } } else { - if uint64(len(*t.MigrateTo)) > cbg.MaxLength { + if len(*t.MigrateTo) > 1000000 { return xerrors.Errorf("Value in field t.MigrateTo was too long") } @@ -1454,7 +1454,7 @@ func (t *SyncSubscribeRepos_Migrate) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1467,7 +1467,7 @@ func (t *SyncSubscribeRepos_Migrate) UnmarshalCBOR(r io.Reader) (err error) { case "did": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1478,10 +1478,10 @@ func (t *SyncSubscribeRepos_Migrate) UnmarshalCBOR(r io.Reader) (err error) { case "seq": { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -1504,7 +1504,7 @@ func (t *SyncSubscribeRepos_Migrate) UnmarshalCBOR(r io.Reader) (err error) { case "time": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1524,7 +1524,7 @@ func (t *SyncSubscribeRepos_Migrate) UnmarshalCBOR(r io.Reader) (err error) { return err } - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1554,7 +1554,7 @@ func (t *SyncSubscribeRepos_RepoOp) MarshalCBOR(w io.Writer) error { } // t.Cid (util.LexLink) (struct) - if uint64(len("cid")) > cbg.MaxLength { + if len("cid") > 1000000 { return xerrors.Errorf("Value in field \"cid\" was too long") } @@ -1570,7 +1570,7 @@ func (t *SyncSubscribeRepos_RepoOp) MarshalCBOR(w io.Writer) error { } // t.Path (string) (string) - if uint64(len("path")) > cbg.MaxLength { + if len("path") > 1000000 { return xerrors.Errorf("Value in field \"path\" was too long") } @@ -1581,7 +1581,7 @@ func (t *SyncSubscribeRepos_RepoOp) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Path)) > cbg.MaxLength { + if len(t.Path) > 1000000 { return xerrors.Errorf("Value in field t.Path was too long") } @@ -1593,7 +1593,7 @@ func (t *SyncSubscribeRepos_RepoOp) MarshalCBOR(w io.Writer) error { } // t.Action (string) (string) - if uint64(len("action")) > cbg.MaxLength { + if len("action") > 1000000 { return xerrors.Errorf("Value in field \"action\" was too long") } @@ -1604,7 +1604,7 @@ func (t *SyncSubscribeRepos_RepoOp) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Action)) > cbg.MaxLength { + if len(t.Action) > 1000000 { return xerrors.Errorf("Value in field t.Action was too long") } @@ -1646,7 +1646,7 @@ func (t *SyncSubscribeRepos_RepoOp) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1679,7 +1679,7 @@ func (t *SyncSubscribeRepos_RepoOp) UnmarshalCBOR(r io.Reader) (err error) { case "path": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1690,7 +1690,7 @@ func (t *SyncSubscribeRepos_RepoOp) UnmarshalCBOR(r io.Reader) (err error) { case "action": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1719,7 +1719,7 @@ func (t *SyncSubscribeRepos_Tombstone) MarshalCBOR(w io.Writer) error { } // t.Did (string) (string) - if uint64(len("did")) > cbg.MaxLength { + if len("did") > 1000000 { return xerrors.Errorf("Value in field \"did\" was too long") } @@ -1730,7 +1730,7 @@ func (t *SyncSubscribeRepos_Tombstone) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Did)) > cbg.MaxLength { + if len(t.Did) > 1000000 { return xerrors.Errorf("Value in field t.Did was too long") } @@ -1742,7 +1742,7 @@ func (t *SyncSubscribeRepos_Tombstone) MarshalCBOR(w io.Writer) error { } // t.Seq (int64) (int64) - if uint64(len("seq")) > cbg.MaxLength { + if len("seq") > 1000000 { return xerrors.Errorf("Value in field \"seq\" was too long") } @@ -1764,7 +1764,7 @@ func (t *SyncSubscribeRepos_Tombstone) MarshalCBOR(w io.Writer) error { } // t.Time (string) (string) - if uint64(len("time")) > cbg.MaxLength { + if len("time") > 1000000 { return xerrors.Errorf("Value in field \"time\" was too long") } @@ -1775,7 +1775,7 @@ func (t *SyncSubscribeRepos_Tombstone) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Time)) > cbg.MaxLength { + if len(t.Time) > 1000000 { return xerrors.Errorf("Value in field t.Time was too long") } @@ -1817,7 +1817,7 @@ func (t *SyncSubscribeRepos_Tombstone) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1830,7 +1830,7 @@ func (t *SyncSubscribeRepos_Tombstone) UnmarshalCBOR(r io.Reader) (err error) { case "did": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1841,10 +1841,10 @@ func (t *SyncSubscribeRepos_Tombstone) UnmarshalCBOR(r io.Reader) (err error) { case "seq": { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -1867,7 +1867,7 @@ func (t *SyncSubscribeRepos_Tombstone) UnmarshalCBOR(r io.Reader) (err error) { case "time": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1896,7 +1896,7 @@ func (t *LabelDefs_SelfLabels) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -1915,7 +1915,7 @@ func (t *LabelDefs_SelfLabels) MarshalCBOR(w io.Writer) error { } // t.Values ([]*atproto.LabelDefs_SelfLabel) (slice) - if uint64(len("values")) > cbg.MaxLength { + if len("values") > 1000000 { return xerrors.Errorf("Value in field \"values\" was too long") } @@ -1926,7 +1926,7 @@ func (t *LabelDefs_SelfLabels) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Values)) > cbg.MaxLength { + if len(t.Values) > 8192 { return xerrors.Errorf("Slice value in field t.Values was too long") } @@ -1980,7 +1980,7 @@ func (t *LabelDefs_SelfLabels) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1993,7 +1993,7 @@ func (t *LabelDefs_SelfLabels) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2018,7 +2018,7 @@ func (t *LabelDefs_SelfLabels) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.Values: array too large (%d)", extra) } @@ -2082,7 +2082,7 @@ func (t *LabelDefs_SelfLabel) MarshalCBOR(w io.Writer) error { } // t.Val (string) (string) - if uint64(len("val")) > cbg.MaxLength { + if len("val") > 1000000 { return xerrors.Errorf("Value in field \"val\" was too long") } @@ -2093,7 +2093,7 @@ func (t *LabelDefs_SelfLabel) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Val)) > cbg.MaxLength { + if len(t.Val) > 1000000 { return xerrors.Errorf("Value in field t.Val was too long") } @@ -2135,7 +2135,7 @@ func (t *LabelDefs_SelfLabel) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2148,7 +2148,7 @@ func (t *LabelDefs_SelfLabel) UnmarshalCBOR(r io.Reader) (err error) { case "val": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2171,12 +2171,16 @@ func (t *LabelDefs_Label) MarshalCBOR(w io.Writer) error { } cw := cbg.NewCborWriter(w) - fieldCount := 7 + fieldCount := 9 if t.Cid == nil { fieldCount-- } + if t.Exp == nil { + fieldCount-- + } + if t.Neg == nil { fieldCount-- } @@ -2185,6 +2189,10 @@ func (t *LabelDefs_Label) MarshalCBOR(w io.Writer) error { fieldCount-- } + if t.Ver == nil { + fieldCount-- + } + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { return err } @@ -2192,7 +2200,7 @@ func (t *LabelDefs_Label) MarshalCBOR(w io.Writer) error { // t.Cid (string) (string) if t.Cid != nil { - if uint64(len("cid")) > cbg.MaxLength { + if len("cid") > 1000000 { return xerrors.Errorf("Value in field \"cid\" was too long") } @@ -2208,7 +2216,7 @@ func (t *LabelDefs_Label) MarshalCBOR(w io.Writer) error { return err } } else { - if uint64(len(*t.Cid)) > cbg.MaxLength { + if len(*t.Cid) > 1000000 { return xerrors.Errorf("Value in field t.Cid was too long") } @@ -2222,7 +2230,7 @@ func (t *LabelDefs_Label) MarshalCBOR(w io.Writer) error { } // t.Cts (string) (string) - if uint64(len("cts")) > cbg.MaxLength { + if len("cts") > 1000000 { return xerrors.Errorf("Value in field \"cts\" was too long") } @@ -2233,7 +2241,7 @@ func (t *LabelDefs_Label) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Cts)) > cbg.MaxLength { + if len(t.Cts) > 1000000 { return xerrors.Errorf("Value in field t.Cts was too long") } @@ -2244,10 +2252,42 @@ func (t *LabelDefs_Label) MarshalCBOR(w io.Writer) error { return err } + // t.Exp (string) (string) + if t.Exp != nil { + + if len("exp") > 1000000 { + return xerrors.Errorf("Value in field \"exp\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("exp"))); err != nil { + return err + } + if _, err := cw.WriteString(string("exp")); err != nil { + return err + } + + if t.Exp == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.Exp) > 1000000 { + return xerrors.Errorf("Value in field t.Exp was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Exp))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.Exp)); err != nil { + return err + } + } + } + // t.Neg (bool) (bool) if t.Neg != nil { - if uint64(len("neg")) > cbg.MaxLength { + if len("neg") > 1000000 { return xerrors.Errorf("Value in field \"neg\" was too long") } @@ -2272,7 +2312,7 @@ func (t *LabelDefs_Label) MarshalCBOR(w io.Writer) error { // t.Sig (util.LexBytes) (slice) if t.Sig != nil { - if uint64(len("sig")) > cbg.MaxLength { + if len("sig") > 1000000 { return xerrors.Errorf("Value in field \"sig\" was too long") } @@ -2283,7 +2323,7 @@ func (t *LabelDefs_Label) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Sig)) > cbg.ByteArrayMaxLen { + if len(t.Sig) > 2097152 { return xerrors.Errorf("Byte array in field t.Sig was too long") } @@ -2298,7 +2338,7 @@ func (t *LabelDefs_Label) MarshalCBOR(w io.Writer) error { } // t.Src (string) (string) - if uint64(len("src")) > cbg.MaxLength { + if len("src") > 1000000 { return xerrors.Errorf("Value in field \"src\" was too long") } @@ -2309,7 +2349,7 @@ func (t *LabelDefs_Label) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Src)) > cbg.MaxLength { + if len(t.Src) > 1000000 { return xerrors.Errorf("Value in field t.Src was too long") } @@ -2321,7 +2361,7 @@ func (t *LabelDefs_Label) MarshalCBOR(w io.Writer) error { } // t.Uri (string) (string) - if uint64(len("uri")) > cbg.MaxLength { + if len("uri") > 1000000 { return xerrors.Errorf("Value in field \"uri\" was too long") } @@ -2332,7 +2372,7 @@ func (t *LabelDefs_Label) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Uri)) > cbg.MaxLength { + if len(t.Uri) > 1000000 { return xerrors.Errorf("Value in field t.Uri was too long") } @@ -2344,7 +2384,7 @@ func (t *LabelDefs_Label) MarshalCBOR(w io.Writer) error { } // t.Val (string) (string) - if uint64(len("val")) > cbg.MaxLength { + if len("val") > 1000000 { return xerrors.Errorf("Value in field \"val\" was too long") } @@ -2355,7 +2395,7 @@ func (t *LabelDefs_Label) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Val)) > cbg.MaxLength { + if len(t.Val) > 1000000 { return xerrors.Errorf("Value in field t.Val was too long") } @@ -2365,6 +2405,38 @@ func (t *LabelDefs_Label) MarshalCBOR(w io.Writer) error { if _, err := cw.WriteString(string(t.Val)); err != nil { return err } + + // t.Ver (int64) (int64) + if t.Ver != nil { + + if len("ver") > 1000000 { + return xerrors.Errorf("Value in field \"ver\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("ver"))); err != nil { + return err + } + if _, err := cw.WriteString(string("ver")); err != nil { + return err + } + + if t.Ver == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if *t.Ver >= 0 { + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(*t.Ver)); err != nil { + return err + } + } else { + if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-*t.Ver-1)); err != nil { + return err + } + } + } + + } return nil } @@ -2397,7 +2469,7 @@ func (t *LabelDefs_Label) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2419,7 +2491,7 @@ func (t *LabelDefs_Label) UnmarshalCBOR(r io.Reader) (err error) { return err } - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2431,13 +2503,34 @@ func (t *LabelDefs_Label) UnmarshalCBOR(r io.Reader) (err error) { case "cts": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } t.Cts = string(sval) } + // t.Exp (string) (string) + case "exp": + + { + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Exp = (*string)(&sval) + } + } // t.Neg (bool) (bool) case "neg": @@ -2479,7 +2572,7 @@ func (t *LabelDefs_Label) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.ByteArrayMaxLen { + if extra > 2097152 { return fmt.Errorf("t.Sig: byte array too large (%d)", extra) } if maj != cbg.MajByteString { @@ -2498,7 +2591,7 @@ func (t *LabelDefs_Label) UnmarshalCBOR(r io.Reader) (err error) { case "src": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2509,7 +2602,7 @@ func (t *LabelDefs_Label) UnmarshalCBOR(r io.Reader) (err error) { case "uri": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2520,13 +2613,49 @@ func (t *LabelDefs_Label) UnmarshalCBOR(r io.Reader) (err error) { case "val": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } t.Val = string(sval) } + // t.Ver (int64) (int64) + case "ver": + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + var extraI int64 + switch maj { + case cbg.MajUnsignedInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 positive overflow") + } + case cbg.MajNegativeInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 negative overflow") + } + extraI = -1 - extraI + default: + return fmt.Errorf("wrong type for int64 field: %d", maj) + } + + t.Ver = (*int64)(&extraI) + } + } default: // Field doesn't exist on this type, so ignore it @@ -2549,7 +2678,7 @@ func (t *LabelSubscribeLabels_Labels) MarshalCBOR(w io.Writer) error { } // t.Seq (int64) (int64) - if uint64(len("seq")) > cbg.MaxLength { + if len("seq") > 1000000 { return xerrors.Errorf("Value in field \"seq\" was too long") } @@ -2571,7 +2700,7 @@ func (t *LabelSubscribeLabels_Labels) MarshalCBOR(w io.Writer) error { } // t.Labels ([]*atproto.LabelDefs_Label) (slice) - if uint64(len("labels")) > cbg.MaxLength { + if len("labels") > 1000000 { return xerrors.Errorf("Value in field \"labels\" was too long") } @@ -2582,7 +2711,7 @@ func (t *LabelSubscribeLabels_Labels) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Labels)) > cbg.MaxLength { + if len(t.Labels) > 8192 { return xerrors.Errorf("Slice value in field t.Labels was too long") } @@ -2627,7 +2756,7 @@ func (t *LabelSubscribeLabels_Labels) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2640,10 +2769,10 @@ func (t *LabelSubscribeLabels_Labels) UnmarshalCBOR(r io.Reader) (err error) { case "seq": { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -2670,7 +2799,7 @@ func (t *LabelSubscribeLabels_Labels) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.Labels: array too large (%d)", extra) } @@ -2738,7 +2867,7 @@ func (t *LabelSubscribeLabels_Info) MarshalCBOR(w io.Writer) error { } // t.Name (string) (string) - if uint64(len("name")) > cbg.MaxLength { + if len("name") > 1000000 { return xerrors.Errorf("Value in field \"name\" was too long") } @@ -2749,7 +2878,7 @@ func (t *LabelSubscribeLabels_Info) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Name)) > cbg.MaxLength { + if len(t.Name) > 1000000 { return xerrors.Errorf("Value in field t.Name was too long") } @@ -2763,7 +2892,7 @@ func (t *LabelSubscribeLabels_Info) MarshalCBOR(w io.Writer) error { // t.Message (string) (string) if t.Message != nil { - if uint64(len("message")) > cbg.MaxLength { + if len("message") > 1000000 { return xerrors.Errorf("Value in field \"message\" was too long") } @@ -2779,7 +2908,7 @@ func (t *LabelSubscribeLabels_Info) MarshalCBOR(w io.Writer) error { return err } } else { - if uint64(len(*t.Message)) > cbg.MaxLength { + if len(*t.Message) > 1000000 { return xerrors.Errorf("Value in field t.Message was too long") } @@ -2823,7 +2952,7 @@ func (t *LabelSubscribeLabels_Info) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2836,7 +2965,7 @@ func (t *LabelSubscribeLabels_Info) UnmarshalCBOR(r io.Reader) (err error) { case "name": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2856,7 +2985,7 @@ func (t *LabelSubscribeLabels_Info) UnmarshalCBOR(r io.Reader) (err error) { return err } - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2886,7 +3015,7 @@ func (t *LabelDefs_LabelValueDefinition) MarshalCBOR(w io.Writer) error { } // t.Blurs (string) (string) - if uint64(len("blurs")) > cbg.MaxLength { + if len("blurs") > 1000000 { return xerrors.Errorf("Value in field \"blurs\" was too long") } @@ -2897,7 +3026,7 @@ func (t *LabelDefs_LabelValueDefinition) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Blurs)) > cbg.MaxLength { + if len(t.Blurs) > 1000000 { return xerrors.Errorf("Value in field t.Blurs was too long") } @@ -2909,7 +3038,7 @@ func (t *LabelDefs_LabelValueDefinition) MarshalCBOR(w io.Writer) error { } // t.Locales ([]*atproto.LabelDefs_LabelValueDefinitionStrings) (slice) - if uint64(len("locales")) > cbg.MaxLength { + if len("locales") > 1000000 { return xerrors.Errorf("Value in field \"locales\" was too long") } @@ -2920,7 +3049,7 @@ func (t *LabelDefs_LabelValueDefinition) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Locales)) > cbg.MaxLength { + if len(t.Locales) > 8192 { return xerrors.Errorf("Slice value in field t.Locales was too long") } @@ -2935,7 +3064,7 @@ func (t *LabelDefs_LabelValueDefinition) MarshalCBOR(w io.Writer) error { } // t.Severity (string) (string) - if uint64(len("severity")) > cbg.MaxLength { + if len("severity") > 1000000 { return xerrors.Errorf("Value in field \"severity\" was too long") } @@ -2946,7 +3075,7 @@ func (t *LabelDefs_LabelValueDefinition) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Severity)) > cbg.MaxLength { + if len(t.Severity) > 1000000 { return xerrors.Errorf("Value in field t.Severity was too long") } @@ -2958,7 +3087,7 @@ func (t *LabelDefs_LabelValueDefinition) MarshalCBOR(w io.Writer) error { } // t.Identifier (string) (string) - if uint64(len("identifier")) > cbg.MaxLength { + if len("identifier") > 1000000 { return xerrors.Errorf("Value in field \"identifier\" was too long") } @@ -2969,7 +3098,7 @@ func (t *LabelDefs_LabelValueDefinition) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Identifier)) > cbg.MaxLength { + if len(t.Identifier) > 1000000 { return xerrors.Errorf("Value in field t.Identifier was too long") } @@ -3011,7 +3140,7 @@ func (t *LabelDefs_LabelValueDefinition) UnmarshalCBOR(r io.Reader) (err error) for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -3024,7 +3153,7 @@ func (t *LabelDefs_LabelValueDefinition) UnmarshalCBOR(r io.Reader) (err error) case "blurs": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -3039,7 +3168,7 @@ func (t *LabelDefs_LabelValueDefinition) UnmarshalCBOR(r io.Reader) (err error) return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.Locales: array too large (%d)", extra) } @@ -3084,7 +3213,7 @@ func (t *LabelDefs_LabelValueDefinition) UnmarshalCBOR(r io.Reader) (err error) case "severity": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -3095,7 +3224,7 @@ func (t *LabelDefs_LabelValueDefinition) UnmarshalCBOR(r io.Reader) (err error) case "identifier": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -3124,7 +3253,7 @@ func (t *LabelDefs_LabelValueDefinitionStrings) MarshalCBOR(w io.Writer) error { } // t.Lang (string) (string) - if uint64(len("lang")) > cbg.MaxLength { + if len("lang") > 1000000 { return xerrors.Errorf("Value in field \"lang\" was too long") } @@ -3135,7 +3264,7 @@ func (t *LabelDefs_LabelValueDefinitionStrings) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Lang)) > cbg.MaxLength { + if len(t.Lang) > 1000000 { return xerrors.Errorf("Value in field t.Lang was too long") } @@ -3147,7 +3276,7 @@ func (t *LabelDefs_LabelValueDefinitionStrings) MarshalCBOR(w io.Writer) error { } // t.Name (string) (string) - if uint64(len("name")) > cbg.MaxLength { + if len("name") > 1000000 { return xerrors.Errorf("Value in field \"name\" was too long") } @@ -3158,7 +3287,7 @@ func (t *LabelDefs_LabelValueDefinitionStrings) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Name)) > cbg.MaxLength { + if len(t.Name) > 1000000 { return xerrors.Errorf("Value in field t.Name was too long") } @@ -3170,7 +3299,7 @@ func (t *LabelDefs_LabelValueDefinitionStrings) MarshalCBOR(w io.Writer) error { } // t.Description (string) (string) - if uint64(len("description")) > cbg.MaxLength { + if len("description") > 1000000 { return xerrors.Errorf("Value in field \"description\" was too long") } @@ -3181,7 +3310,7 @@ func (t *LabelDefs_LabelValueDefinitionStrings) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Description)) > cbg.MaxLength { + if len(t.Description) > 1000000 { return xerrors.Errorf("Value in field t.Description was too long") } @@ -3223,7 +3352,7 @@ func (t *LabelDefs_LabelValueDefinitionStrings) UnmarshalCBOR(r io.Reader) (err for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -3236,7 +3365,7 @@ func (t *LabelDefs_LabelValueDefinitionStrings) UnmarshalCBOR(r io.Reader) (err case "lang": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -3247,7 +3376,7 @@ func (t *LabelDefs_LabelValueDefinitionStrings) UnmarshalCBOR(r io.Reader) (err case "name": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -3258,7 +3387,7 @@ func (t *LabelDefs_LabelValueDefinitionStrings) UnmarshalCBOR(r io.Reader) (err case "description": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } diff --git a/api/bsky/cbor_gen.go b/api/bsky/cbor_gen.go index ba942c88..9ead4652 100644 --- a/api/bsky/cbor_gen.go +++ b/api/bsky/cbor_gen.go @@ -64,7 +64,7 @@ func (t *FeedPost) MarshalCBOR(w io.Writer) error { // t.Tags ([]string) (slice) if t.Tags != nil { - if uint64(len("tags")) > cbg.MaxLength { + if len("tags") > 1000000 { return xerrors.Errorf("Value in field \"tags\" was too long") } @@ -75,7 +75,7 @@ func (t *FeedPost) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Tags)) > cbg.MaxLength { + if len(t.Tags) > 8192 { return xerrors.Errorf("Slice value in field t.Tags was too long") } @@ -83,7 +83,7 @@ func (t *FeedPost) MarshalCBOR(w io.Writer) error { return err } for _, v := range t.Tags { - if uint64(len(v)) > cbg.MaxLength { + if len(v) > 1000000 { return xerrors.Errorf("Value in field v was too long") } @@ -98,7 +98,7 @@ func (t *FeedPost) MarshalCBOR(w io.Writer) error { } // t.Text (string) (string) - if uint64(len("text")) > cbg.MaxLength { + if len("text") > 1000000 { return xerrors.Errorf("Value in field \"text\" was too long") } @@ -109,7 +109,7 @@ func (t *FeedPost) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Text)) > cbg.MaxLength { + if len(t.Text) > 1000000 { return xerrors.Errorf("Value in field t.Text was too long") } @@ -121,7 +121,7 @@ func (t *FeedPost) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -142,7 +142,7 @@ func (t *FeedPost) MarshalCBOR(w io.Writer) error { // t.Embed (bsky.FeedPost_Embed) (struct) if t.Embed != nil { - if uint64(len("embed")) > cbg.MaxLength { + if len("embed") > 1000000 { return xerrors.Errorf("Value in field \"embed\" was too long") } @@ -161,7 +161,7 @@ func (t *FeedPost) MarshalCBOR(w io.Writer) error { // t.Langs ([]string) (slice) if t.Langs != nil { - if uint64(len("langs")) > cbg.MaxLength { + if len("langs") > 1000000 { return xerrors.Errorf("Value in field \"langs\" was too long") } @@ -172,7 +172,7 @@ func (t *FeedPost) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Langs)) > cbg.MaxLength { + if len(t.Langs) > 8192 { return xerrors.Errorf("Slice value in field t.Langs was too long") } @@ -180,7 +180,7 @@ func (t *FeedPost) MarshalCBOR(w io.Writer) error { return err } for _, v := range t.Langs { - if uint64(len(v)) > cbg.MaxLength { + if len(v) > 1000000 { return xerrors.Errorf("Value in field v was too long") } @@ -197,7 +197,7 @@ func (t *FeedPost) MarshalCBOR(w io.Writer) error { // t.Reply (bsky.FeedPost_ReplyRef) (struct) if t.Reply != nil { - if uint64(len("reply")) > cbg.MaxLength { + if len("reply") > 1000000 { return xerrors.Errorf("Value in field \"reply\" was too long") } @@ -216,7 +216,7 @@ func (t *FeedPost) MarshalCBOR(w io.Writer) error { // t.Facets ([]*bsky.RichtextFacet) (slice) if t.Facets != nil { - if uint64(len("facets")) > cbg.MaxLength { + if len("facets") > 1000000 { return xerrors.Errorf("Value in field \"facets\" was too long") } @@ -227,7 +227,7 @@ func (t *FeedPost) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Facets)) > cbg.MaxLength { + if len(t.Facets) > 8192 { return xerrors.Errorf("Slice value in field t.Facets was too long") } @@ -245,7 +245,7 @@ func (t *FeedPost) MarshalCBOR(w io.Writer) error { // t.Labels (bsky.FeedPost_Labels) (struct) if t.Labels != nil { - if uint64(len("labels")) > cbg.MaxLength { + if len("labels") > 1000000 { return xerrors.Errorf("Value in field \"labels\" was too long") } @@ -264,7 +264,7 @@ func (t *FeedPost) MarshalCBOR(w io.Writer) error { // t.Entities ([]*bsky.FeedPost_Entity) (slice) if t.Entities != nil { - if uint64(len("entities")) > cbg.MaxLength { + if len("entities") > 1000000 { return xerrors.Errorf("Value in field \"entities\" was too long") } @@ -275,7 +275,7 @@ func (t *FeedPost) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Entities)) > cbg.MaxLength { + if len(t.Entities) > 8192 { return xerrors.Errorf("Slice value in field t.Entities was too long") } @@ -291,7 +291,7 @@ func (t *FeedPost) MarshalCBOR(w io.Writer) error { } // t.CreatedAt (string) (string) - if uint64(len("createdAt")) > cbg.MaxLength { + if len("createdAt") > 1000000 { return xerrors.Errorf("Value in field \"createdAt\" was too long") } @@ -302,7 +302,7 @@ func (t *FeedPost) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.CreatedAt)) > cbg.MaxLength { + if len(t.CreatedAt) > 1000000 { return xerrors.Errorf("Value in field t.CreatedAt was too long") } @@ -344,7 +344,7 @@ func (t *FeedPost) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -361,7 +361,7 @@ func (t *FeedPost) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.Tags: array too large (%d)", extra) } @@ -383,7 +383,7 @@ func (t *FeedPost) UnmarshalCBOR(r io.Reader) (err error) { _ = err { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -397,7 +397,7 @@ func (t *FeedPost) UnmarshalCBOR(r io.Reader) (err error) { case "text": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -408,7 +408,7 @@ func (t *FeedPost) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -443,7 +443,7 @@ func (t *FeedPost) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.Langs: array too large (%d)", extra) } @@ -465,7 +465,7 @@ func (t *FeedPost) UnmarshalCBOR(r io.Reader) (err error) { _ = err { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -503,7 +503,7 @@ func (t *FeedPost) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.Facets: array too large (%d)", extra) } @@ -572,7 +572,7 @@ func (t *FeedPost) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.Entities: array too large (%d)", extra) } @@ -617,7 +617,7 @@ func (t *FeedPost) UnmarshalCBOR(r io.Reader) (err error) { case "createdAt": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -646,7 +646,7 @@ func (t *FeedRepost) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -665,7 +665,7 @@ func (t *FeedRepost) MarshalCBOR(w io.Writer) error { } // t.Subject (atproto.RepoStrongRef) (struct) - if uint64(len("subject")) > cbg.MaxLength { + if len("subject") > 1000000 { return xerrors.Errorf("Value in field \"subject\" was too long") } @@ -681,7 +681,7 @@ func (t *FeedRepost) MarshalCBOR(w io.Writer) error { } // t.CreatedAt (string) (string) - if uint64(len("createdAt")) > cbg.MaxLength { + if len("createdAt") > 1000000 { return xerrors.Errorf("Value in field \"createdAt\" was too long") } @@ -692,7 +692,7 @@ func (t *FeedRepost) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.CreatedAt)) > cbg.MaxLength { + if len(t.CreatedAt) > 1000000 { return xerrors.Errorf("Value in field t.CreatedAt was too long") } @@ -734,7 +734,7 @@ func (t *FeedRepost) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -747,7 +747,7 @@ func (t *FeedRepost) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -778,7 +778,7 @@ func (t *FeedRepost) UnmarshalCBOR(r io.Reader) (err error) { case "createdAt": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -807,7 +807,7 @@ func (t *FeedPost_Entity) MarshalCBOR(w io.Writer) error { } // t.Type (string) (string) - if uint64(len("type")) > cbg.MaxLength { + if len("type") > 1000000 { return xerrors.Errorf("Value in field \"type\" was too long") } @@ -818,7 +818,7 @@ func (t *FeedPost_Entity) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Type)) > cbg.MaxLength { + if len(t.Type) > 1000000 { return xerrors.Errorf("Value in field t.Type was too long") } @@ -830,7 +830,7 @@ func (t *FeedPost_Entity) MarshalCBOR(w io.Writer) error { } // t.Index (bsky.FeedPost_TextSlice) (struct) - if uint64(len("index")) > cbg.MaxLength { + if len("index") > 1000000 { return xerrors.Errorf("Value in field \"index\" was too long") } @@ -846,7 +846,7 @@ func (t *FeedPost_Entity) MarshalCBOR(w io.Writer) error { } // t.Value (string) (string) - if uint64(len("value")) > cbg.MaxLength { + if len("value") > 1000000 { return xerrors.Errorf("Value in field \"value\" was too long") } @@ -857,7 +857,7 @@ func (t *FeedPost_Entity) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Value)) > cbg.MaxLength { + if len(t.Value) > 1000000 { return xerrors.Errorf("Value in field t.Value was too long") } @@ -899,7 +899,7 @@ func (t *FeedPost_Entity) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -912,7 +912,7 @@ func (t *FeedPost_Entity) UnmarshalCBOR(r io.Reader) (err error) { case "type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -943,7 +943,7 @@ func (t *FeedPost_Entity) UnmarshalCBOR(r io.Reader) (err error) { case "value": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -972,7 +972,7 @@ func (t *FeedPost_ReplyRef) MarshalCBOR(w io.Writer) error { } // t.Root (atproto.RepoStrongRef) (struct) - if uint64(len("root")) > cbg.MaxLength { + if len("root") > 1000000 { return xerrors.Errorf("Value in field \"root\" was too long") } @@ -988,7 +988,7 @@ func (t *FeedPost_ReplyRef) MarshalCBOR(w io.Writer) error { } // t.Parent (atproto.RepoStrongRef) (struct) - if uint64(len("parent")) > cbg.MaxLength { + if len("parent") > 1000000 { return xerrors.Errorf("Value in field \"parent\" was too long") } @@ -1034,7 +1034,7 @@ func (t *FeedPost_ReplyRef) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1105,7 +1105,7 @@ func (t *FeedPost_TextSlice) MarshalCBOR(w io.Writer) error { } // t.End (int64) (int64) - if uint64(len("end")) > cbg.MaxLength { + if len("end") > 1000000 { return xerrors.Errorf("Value in field \"end\" was too long") } @@ -1127,7 +1127,7 @@ func (t *FeedPost_TextSlice) MarshalCBOR(w io.Writer) error { } // t.Start (int64) (int64) - if uint64(len("start")) > cbg.MaxLength { + if len("start") > 1000000 { return xerrors.Errorf("Value in field \"start\" was too long") } @@ -1147,6 +1147,7 @@ func (t *FeedPost_TextSlice) MarshalCBOR(w io.Writer) error { return err } } + return nil } @@ -1179,7 +1180,7 @@ func (t *FeedPost_TextSlice) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1192,10 +1193,10 @@ func (t *FeedPost_TextSlice) UnmarshalCBOR(r io.Reader) (err error) { case "end": { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -1218,10 +1219,10 @@ func (t *FeedPost_TextSlice) UnmarshalCBOR(r io.Reader) (err error) { case "start": { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -1262,7 +1263,7 @@ func (t *EmbedImages) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -1281,7 +1282,7 @@ func (t *EmbedImages) MarshalCBOR(w io.Writer) error { } // t.Images ([]*bsky.EmbedImages_Image) (slice) - if uint64(len("images")) > cbg.MaxLength { + if len("images") > 1000000 { return xerrors.Errorf("Value in field \"images\" was too long") } @@ -1292,7 +1293,7 @@ func (t *EmbedImages) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Images)) > cbg.MaxLength { + if len(t.Images) > 8192 { return xerrors.Errorf("Slice value in field t.Images was too long") } @@ -1337,7 +1338,7 @@ func (t *EmbedImages) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1350,7 +1351,7 @@ func (t *EmbedImages) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1365,7 +1366,7 @@ func (t *EmbedImages) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.Images: array too large (%d)", extra) } @@ -1428,7 +1429,7 @@ func (t *EmbedExternal) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -1447,7 +1448,7 @@ func (t *EmbedExternal) MarshalCBOR(w io.Writer) error { } // t.External (bsky.EmbedExternal_External) (struct) - if uint64(len("external")) > cbg.MaxLength { + if len("external") > 1000000 { return xerrors.Errorf("Value in field \"external\" was too long") } @@ -1493,7 +1494,7 @@ func (t *EmbedExternal) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1506,7 +1507,7 @@ func (t *EmbedExternal) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1560,7 +1561,7 @@ func (t *EmbedExternal_External) MarshalCBOR(w io.Writer) error { } // t.Uri (string) (string) - if uint64(len("uri")) > cbg.MaxLength { + if len("uri") > 1000000 { return xerrors.Errorf("Value in field \"uri\" was too long") } @@ -1571,7 +1572,7 @@ func (t *EmbedExternal_External) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Uri)) > cbg.MaxLength { + if len(t.Uri) > 1000000 { return xerrors.Errorf("Value in field t.Uri was too long") } @@ -1585,7 +1586,7 @@ func (t *EmbedExternal_External) MarshalCBOR(w io.Writer) error { // t.Thumb (util.LexBlob) (struct) if t.Thumb != nil { - if uint64(len("thumb")) > cbg.MaxLength { + if len("thumb") > 1000000 { return xerrors.Errorf("Value in field \"thumb\" was too long") } @@ -1602,7 +1603,7 @@ func (t *EmbedExternal_External) MarshalCBOR(w io.Writer) error { } // t.Title (string) (string) - if uint64(len("title")) > cbg.MaxLength { + if len("title") > 1000000 { return xerrors.Errorf("Value in field \"title\" was too long") } @@ -1613,7 +1614,7 @@ func (t *EmbedExternal_External) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Title)) > cbg.MaxLength { + if len(t.Title) > 1000000 { return xerrors.Errorf("Value in field t.Title was too long") } @@ -1625,7 +1626,7 @@ func (t *EmbedExternal_External) MarshalCBOR(w io.Writer) error { } // t.Description (string) (string) - if uint64(len("description")) > cbg.MaxLength { + if len("description") > 1000000 { return xerrors.Errorf("Value in field \"description\" was too long") } @@ -1636,7 +1637,7 @@ func (t *EmbedExternal_External) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Description)) > cbg.MaxLength { + if len(t.Description) > 1000000 { return xerrors.Errorf("Value in field t.Description was too long") } @@ -1678,7 +1679,7 @@ func (t *EmbedExternal_External) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1691,7 +1692,7 @@ func (t *EmbedExternal_External) UnmarshalCBOR(r io.Reader) (err error) { case "uri": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1722,7 +1723,7 @@ func (t *EmbedExternal_External) UnmarshalCBOR(r io.Reader) (err error) { case "title": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1733,7 +1734,7 @@ func (t *EmbedExternal_External) UnmarshalCBOR(r io.Reader) (err error) { case "description": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1767,7 +1768,7 @@ func (t *EmbedImages_Image) MarshalCBOR(w io.Writer) error { } // t.Alt (string) (string) - if uint64(len("alt")) > cbg.MaxLength { + if len("alt") > 1000000 { return xerrors.Errorf("Value in field \"alt\" was too long") } @@ -1778,7 +1779,7 @@ func (t *EmbedImages_Image) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Alt)) > cbg.MaxLength { + if len(t.Alt) > 1000000 { return xerrors.Errorf("Value in field t.Alt was too long") } @@ -1790,7 +1791,7 @@ func (t *EmbedImages_Image) MarshalCBOR(w io.Writer) error { } // t.Image (util.LexBlob) (struct) - if uint64(len("image")) > cbg.MaxLength { + if len("image") > 1000000 { return xerrors.Errorf("Value in field \"image\" was too long") } @@ -1808,7 +1809,7 @@ func (t *EmbedImages_Image) MarshalCBOR(w io.Writer) error { // t.AspectRatio (bsky.EmbedImages_AspectRatio) (struct) if t.AspectRatio != nil { - if uint64(len("aspectRatio")) > cbg.MaxLength { + if len("aspectRatio") > 1000000 { return xerrors.Errorf("Value in field \"aspectRatio\" was too long") } @@ -1855,7 +1856,7 @@ func (t *EmbedImages_Image) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1868,7 +1869,7 @@ func (t *EmbedImages_Image) UnmarshalCBOR(r io.Reader) (err error) { case "alt": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -1937,7 +1938,7 @@ func (t *GraphFollow) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -1956,7 +1957,7 @@ func (t *GraphFollow) MarshalCBOR(w io.Writer) error { } // t.Subject (string) (string) - if uint64(len("subject")) > cbg.MaxLength { + if len("subject") > 1000000 { return xerrors.Errorf("Value in field \"subject\" was too long") } @@ -1967,7 +1968,7 @@ func (t *GraphFollow) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Subject)) > cbg.MaxLength { + if len(t.Subject) > 1000000 { return xerrors.Errorf("Value in field t.Subject was too long") } @@ -1979,7 +1980,7 @@ func (t *GraphFollow) MarshalCBOR(w io.Writer) error { } // t.CreatedAt (string) (string) - if uint64(len("createdAt")) > cbg.MaxLength { + if len("createdAt") > 1000000 { return xerrors.Errorf("Value in field \"createdAt\" was too long") } @@ -1990,7 +1991,7 @@ func (t *GraphFollow) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.CreatedAt)) > cbg.MaxLength { + if len(t.CreatedAt) > 1000000 { return xerrors.Errorf("Value in field t.CreatedAt was too long") } @@ -2032,7 +2033,7 @@ func (t *GraphFollow) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2045,7 +2046,7 @@ func (t *GraphFollow) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2056,7 +2057,7 @@ func (t *GraphFollow) UnmarshalCBOR(r io.Reader) (err error) { case "subject": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2067,7 +2068,7 @@ func (t *GraphFollow) UnmarshalCBOR(r io.Reader) (err error) { case "createdAt": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2117,7 +2118,7 @@ func (t *ActorProfile) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -2138,7 +2139,7 @@ func (t *ActorProfile) MarshalCBOR(w io.Writer) error { // t.Avatar (util.LexBlob) (struct) if t.Avatar != nil { - if uint64(len("avatar")) > cbg.MaxLength { + if len("avatar") > 1000000 { return xerrors.Errorf("Value in field \"avatar\" was too long") } @@ -2157,7 +2158,7 @@ func (t *ActorProfile) MarshalCBOR(w io.Writer) error { // t.Banner (util.LexBlob) (struct) if t.Banner != nil { - if uint64(len("banner")) > cbg.MaxLength { + if len("banner") > 1000000 { return xerrors.Errorf("Value in field \"banner\" was too long") } @@ -2176,7 +2177,7 @@ func (t *ActorProfile) MarshalCBOR(w io.Writer) error { // t.Labels (bsky.ActorProfile_Labels) (struct) if t.Labels != nil { - if uint64(len("labels")) > cbg.MaxLength { + if len("labels") > 1000000 { return xerrors.Errorf("Value in field \"labels\" was too long") } @@ -2195,7 +2196,7 @@ func (t *ActorProfile) MarshalCBOR(w io.Writer) error { // t.Description (string) (string) if t.Description != nil { - if uint64(len("description")) > cbg.MaxLength { + if len("description") > 1000000 { return xerrors.Errorf("Value in field \"description\" was too long") } @@ -2211,7 +2212,7 @@ func (t *ActorProfile) MarshalCBOR(w io.Writer) error { return err } } else { - if uint64(len(*t.Description)) > cbg.MaxLength { + if len(*t.Description) > 1000000 { return xerrors.Errorf("Value in field t.Description was too long") } @@ -2227,7 +2228,7 @@ func (t *ActorProfile) MarshalCBOR(w io.Writer) error { // t.DisplayName (string) (string) if t.DisplayName != nil { - if uint64(len("displayName")) > cbg.MaxLength { + if len("displayName") > 1000000 { return xerrors.Errorf("Value in field \"displayName\" was too long") } @@ -2243,7 +2244,7 @@ func (t *ActorProfile) MarshalCBOR(w io.Writer) error { return err } } else { - if uint64(len(*t.DisplayName)) > cbg.MaxLength { + if len(*t.DisplayName) > 1000000 { return xerrors.Errorf("Value in field t.DisplayName was too long") } @@ -2287,7 +2288,7 @@ func (t *ActorProfile) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2300,7 +2301,7 @@ func (t *ActorProfile) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2380,7 +2381,7 @@ func (t *ActorProfile) UnmarshalCBOR(r io.Reader) (err error) { return err } - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2401,7 +2402,7 @@ func (t *ActorProfile) UnmarshalCBOR(r io.Reader) (err error) { return err } - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2431,7 +2432,7 @@ func (t *EmbedRecord) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -2450,7 +2451,7 @@ func (t *EmbedRecord) MarshalCBOR(w io.Writer) error { } // t.Record (atproto.RepoStrongRef) (struct) - if uint64(len("record")) > cbg.MaxLength { + if len("record") > 1000000 { return xerrors.Errorf("Value in field \"record\" was too long") } @@ -2496,7 +2497,7 @@ func (t *EmbedRecord) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2509,7 +2510,7 @@ func (t *EmbedRecord) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2558,7 +2559,7 @@ func (t *FeedLike) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -2577,7 +2578,7 @@ func (t *FeedLike) MarshalCBOR(w io.Writer) error { } // t.Subject (atproto.RepoStrongRef) (struct) - if uint64(len("subject")) > cbg.MaxLength { + if len("subject") > 1000000 { return xerrors.Errorf("Value in field \"subject\" was too long") } @@ -2593,7 +2594,7 @@ func (t *FeedLike) MarshalCBOR(w io.Writer) error { } // t.CreatedAt (string) (string) - if uint64(len("createdAt")) > cbg.MaxLength { + if len("createdAt") > 1000000 { return xerrors.Errorf("Value in field \"createdAt\" was too long") } @@ -2604,7 +2605,7 @@ func (t *FeedLike) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.CreatedAt)) > cbg.MaxLength { + if len(t.CreatedAt) > 1000000 { return xerrors.Errorf("Value in field t.CreatedAt was too long") } @@ -2646,7 +2647,7 @@ func (t *FeedLike) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2659,7 +2660,7 @@ func (t *FeedLike) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2690,7 +2691,7 @@ func (t *FeedLike) UnmarshalCBOR(r io.Reader) (err error) { case "createdAt": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2719,7 +2720,7 @@ func (t *RichtextFacet) MarshalCBOR(w io.Writer) error { } // t.Index (bsky.RichtextFacet_ByteSlice) (struct) - if uint64(len("index")) > cbg.MaxLength { + if len("index") > 1000000 { return xerrors.Errorf("Value in field \"index\" was too long") } @@ -2735,7 +2736,7 @@ func (t *RichtextFacet) MarshalCBOR(w io.Writer) error { } // t.Features ([]*bsky.RichtextFacet_Features_Elem) (slice) - if uint64(len("features")) > cbg.MaxLength { + if len("features") > 1000000 { return xerrors.Errorf("Value in field \"features\" was too long") } @@ -2746,7 +2747,7 @@ func (t *RichtextFacet) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Features)) > cbg.MaxLength { + if len(t.Features) > 8192 { return xerrors.Errorf("Slice value in field t.Features was too long") } @@ -2791,7 +2792,7 @@ func (t *RichtextFacet) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2828,7 +2829,7 @@ func (t *RichtextFacet) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.Features: array too large (%d)", extra) } @@ -2891,7 +2892,7 @@ func (t *RichtextFacet_ByteSlice) MarshalCBOR(w io.Writer) error { } // t.ByteEnd (int64) (int64) - if uint64(len("byteEnd")) > cbg.MaxLength { + if len("byteEnd") > 1000000 { return xerrors.Errorf("Value in field \"byteEnd\" was too long") } @@ -2913,7 +2914,7 @@ func (t *RichtextFacet_ByteSlice) MarshalCBOR(w io.Writer) error { } // t.ByteStart (int64) (int64) - if uint64(len("byteStart")) > cbg.MaxLength { + if len("byteStart") > 1000000 { return xerrors.Errorf("Value in field \"byteStart\" was too long") } @@ -2933,6 +2934,7 @@ func (t *RichtextFacet_ByteSlice) MarshalCBOR(w io.Writer) error { return err } } + return nil } @@ -2965,7 +2967,7 @@ func (t *RichtextFacet_ByteSlice) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -2978,10 +2980,10 @@ func (t *RichtextFacet_ByteSlice) UnmarshalCBOR(r io.Reader) (err error) { case "byteEnd": { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -3004,10 +3006,10 @@ func (t *RichtextFacet_ByteSlice) UnmarshalCBOR(r io.Reader) (err error) { case "byteStart": { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -3048,7 +3050,7 @@ func (t *RichtextFacet_Link) MarshalCBOR(w io.Writer) error { } // t.Uri (string) (string) - if uint64(len("uri")) > cbg.MaxLength { + if len("uri") > 1000000 { return xerrors.Errorf("Value in field \"uri\" was too long") } @@ -3059,7 +3061,7 @@ func (t *RichtextFacet_Link) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Uri)) > cbg.MaxLength { + if len(t.Uri) > 1000000 { return xerrors.Errorf("Value in field t.Uri was too long") } @@ -3071,7 +3073,7 @@ func (t *RichtextFacet_Link) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -3120,7 +3122,7 @@ func (t *RichtextFacet_Link) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -3133,7 +3135,7 @@ func (t *RichtextFacet_Link) UnmarshalCBOR(r io.Reader) (err error) { case "uri": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -3144,7 +3146,7 @@ func (t *RichtextFacet_Link) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -3173,7 +3175,7 @@ func (t *RichtextFacet_Mention) MarshalCBOR(w io.Writer) error { } // t.Did (string) (string) - if uint64(len("did")) > cbg.MaxLength { + if len("did") > 1000000 { return xerrors.Errorf("Value in field \"did\" was too long") } @@ -3184,7 +3186,7 @@ func (t *RichtextFacet_Mention) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Did)) > cbg.MaxLength { + if len(t.Did) > 1000000 { return xerrors.Errorf("Value in field t.Did was too long") } @@ -3196,7 +3198,7 @@ func (t *RichtextFacet_Mention) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -3245,7 +3247,7 @@ func (t *RichtextFacet_Mention) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -3258,7 +3260,7 @@ func (t *RichtextFacet_Mention) UnmarshalCBOR(r io.Reader) (err error) { case "did": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -3269,7 +3271,7 @@ func (t *RichtextFacet_Mention) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -3298,7 +3300,7 @@ func (t *RichtextFacet_Tag) MarshalCBOR(w io.Writer) error { } // t.Tag (string) (string) - if uint64(len("tag")) > cbg.MaxLength { + if len("tag") > 1000000 { return xerrors.Errorf("Value in field \"tag\" was too long") } @@ -3309,7 +3311,7 @@ func (t *RichtextFacet_Tag) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Tag)) > cbg.MaxLength { + if len(t.Tag) > 1000000 { return xerrors.Errorf("Value in field t.Tag was too long") } @@ -3321,7 +3323,7 @@ func (t *RichtextFacet_Tag) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -3370,7 +3372,7 @@ func (t *RichtextFacet_Tag) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -3383,7 +3385,7 @@ func (t *RichtextFacet_Tag) UnmarshalCBOR(r io.Reader) (err error) { case "tag": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -3394,7 +3396,7 @@ func (t *RichtextFacet_Tag) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -3423,7 +3425,7 @@ func (t *EmbedRecordWithMedia) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -3442,7 +3444,7 @@ func (t *EmbedRecordWithMedia) MarshalCBOR(w io.Writer) error { } // t.Media (bsky.EmbedRecordWithMedia_Media) (struct) - if uint64(len("media")) > cbg.MaxLength { + if len("media") > 1000000 { return xerrors.Errorf("Value in field \"media\" was too long") } @@ -3458,7 +3460,7 @@ func (t *EmbedRecordWithMedia) MarshalCBOR(w io.Writer) error { } // t.Record (bsky.EmbedRecord) (struct) - if uint64(len("record")) > cbg.MaxLength { + if len("record") > 1000000 { return xerrors.Errorf("Value in field \"record\" was too long") } @@ -3504,7 +3506,7 @@ func (t *EmbedRecordWithMedia) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -3517,7 +3519,7 @@ func (t *EmbedRecordWithMedia) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -3586,7 +3588,7 @@ func (t *FeedDefs_NotFoundPost) MarshalCBOR(w io.Writer) error { } // t.Uri (string) (string) - if uint64(len("uri")) > cbg.MaxLength { + if len("uri") > 1000000 { return xerrors.Errorf("Value in field \"uri\" was too long") } @@ -3597,7 +3599,7 @@ func (t *FeedDefs_NotFoundPost) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Uri)) > cbg.MaxLength { + if len(t.Uri) > 1000000 { return xerrors.Errorf("Value in field t.Uri was too long") } @@ -3609,7 +3611,7 @@ func (t *FeedDefs_NotFoundPost) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -3628,7 +3630,7 @@ func (t *FeedDefs_NotFoundPost) MarshalCBOR(w io.Writer) error { } // t.NotFound (bool) (bool) - if uint64(len("notFound")) > cbg.MaxLength { + if len("notFound") > 1000000 { return xerrors.Errorf("Value in field \"notFound\" was too long") } @@ -3674,7 +3676,7 @@ func (t *FeedDefs_NotFoundPost) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -3687,7 +3689,7 @@ func (t *FeedDefs_NotFoundPost) UnmarshalCBOR(r io.Reader) (err error) { case "uri": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -3698,7 +3700,7 @@ func (t *FeedDefs_NotFoundPost) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -3745,7 +3747,7 @@ func (t *GraphBlock) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -3764,7 +3766,7 @@ func (t *GraphBlock) MarshalCBOR(w io.Writer) error { } // t.Subject (string) (string) - if uint64(len("subject")) > cbg.MaxLength { + if len("subject") > 1000000 { return xerrors.Errorf("Value in field \"subject\" was too long") } @@ -3775,7 +3777,7 @@ func (t *GraphBlock) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Subject)) > cbg.MaxLength { + if len(t.Subject) > 1000000 { return xerrors.Errorf("Value in field t.Subject was too long") } @@ -3787,7 +3789,7 @@ func (t *GraphBlock) MarshalCBOR(w io.Writer) error { } // t.CreatedAt (string) (string) - if uint64(len("createdAt")) > cbg.MaxLength { + if len("createdAt") > 1000000 { return xerrors.Errorf("Value in field \"createdAt\" was too long") } @@ -3798,7 +3800,7 @@ func (t *GraphBlock) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.CreatedAt)) > cbg.MaxLength { + if len(t.CreatedAt) > 1000000 { return xerrors.Errorf("Value in field t.CreatedAt was too long") } @@ -3840,7 +3842,7 @@ func (t *GraphBlock) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -3853,7 +3855,7 @@ func (t *GraphBlock) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -3864,7 +3866,7 @@ func (t *GraphBlock) UnmarshalCBOR(r io.Reader) (err error) { case "subject": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -3875,7 +3877,7 @@ func (t *GraphBlock) UnmarshalCBOR(r io.Reader) (err error) { case "createdAt": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -3921,7 +3923,7 @@ func (t *GraphList) MarshalCBOR(w io.Writer) error { } // t.Name (string) (string) - if uint64(len("name")) > cbg.MaxLength { + if len("name") > 1000000 { return xerrors.Errorf("Value in field \"name\" was too long") } @@ -3932,7 +3934,7 @@ func (t *GraphList) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Name)) > cbg.MaxLength { + if len(t.Name) > 1000000 { return xerrors.Errorf("Value in field t.Name was too long") } @@ -3944,7 +3946,7 @@ func (t *GraphList) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -3965,7 +3967,7 @@ func (t *GraphList) MarshalCBOR(w io.Writer) error { // t.Avatar (util.LexBlob) (struct) if t.Avatar != nil { - if uint64(len("avatar")) > cbg.MaxLength { + if len("avatar") > 1000000 { return xerrors.Errorf("Value in field \"avatar\" was too long") } @@ -3984,7 +3986,7 @@ func (t *GraphList) MarshalCBOR(w io.Writer) error { // t.Labels (bsky.GraphList_Labels) (struct) if t.Labels != nil { - if uint64(len("labels")) > cbg.MaxLength { + if len("labels") > 1000000 { return xerrors.Errorf("Value in field \"labels\" was too long") } @@ -4001,7 +4003,7 @@ func (t *GraphList) MarshalCBOR(w io.Writer) error { } // t.Purpose (string) (string) - if uint64(len("purpose")) > cbg.MaxLength { + if len("purpose") > 1000000 { return xerrors.Errorf("Value in field \"purpose\" was too long") } @@ -4017,7 +4019,7 @@ func (t *GraphList) MarshalCBOR(w io.Writer) error { return err } } else { - if uint64(len(*t.Purpose)) > cbg.MaxLength { + if len(*t.Purpose) > 1000000 { return xerrors.Errorf("Value in field t.Purpose was too long") } @@ -4030,7 +4032,7 @@ func (t *GraphList) MarshalCBOR(w io.Writer) error { } // t.CreatedAt (string) (string) - if uint64(len("createdAt")) > cbg.MaxLength { + if len("createdAt") > 1000000 { return xerrors.Errorf("Value in field \"createdAt\" was too long") } @@ -4041,7 +4043,7 @@ func (t *GraphList) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.CreatedAt)) > cbg.MaxLength { + if len(t.CreatedAt) > 1000000 { return xerrors.Errorf("Value in field t.CreatedAt was too long") } @@ -4055,7 +4057,7 @@ func (t *GraphList) MarshalCBOR(w io.Writer) error { // t.Description (string) (string) if t.Description != nil { - if uint64(len("description")) > cbg.MaxLength { + if len("description") > 1000000 { return xerrors.Errorf("Value in field \"description\" was too long") } @@ -4071,7 +4073,7 @@ func (t *GraphList) MarshalCBOR(w io.Writer) error { return err } } else { - if uint64(len(*t.Description)) > cbg.MaxLength { + if len(*t.Description) > 1000000 { return xerrors.Errorf("Value in field t.Description was too long") } @@ -4087,7 +4089,7 @@ func (t *GraphList) MarshalCBOR(w io.Writer) error { // t.DescriptionFacets ([]*bsky.RichtextFacet) (slice) if t.DescriptionFacets != nil { - if uint64(len("descriptionFacets")) > cbg.MaxLength { + if len("descriptionFacets") > 1000000 { return xerrors.Errorf("Value in field \"descriptionFacets\" was too long") } @@ -4098,7 +4100,7 @@ func (t *GraphList) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.DescriptionFacets)) > cbg.MaxLength { + if len(t.DescriptionFacets) > 8192 { return xerrors.Errorf("Slice value in field t.DescriptionFacets was too long") } @@ -4144,7 +4146,7 @@ func (t *GraphList) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -4157,7 +4159,7 @@ func (t *GraphList) UnmarshalCBOR(r io.Reader) (err error) { case "name": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -4168,7 +4170,7 @@ func (t *GraphList) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -4228,7 +4230,7 @@ func (t *GraphList) UnmarshalCBOR(r io.Reader) (err error) { return err } - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -4240,7 +4242,7 @@ func (t *GraphList) UnmarshalCBOR(r io.Reader) (err error) { case "createdAt": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -4260,7 +4262,7 @@ func (t *GraphList) UnmarshalCBOR(r io.Reader) (err error) { return err } - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -4276,7 +4278,7 @@ func (t *GraphList) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.DescriptionFacets: array too large (%d)", extra) } @@ -4339,7 +4341,7 @@ func (t *GraphListitem) MarshalCBOR(w io.Writer) error { } // t.List (string) (string) - if uint64(len("list")) > cbg.MaxLength { + if len("list") > 1000000 { return xerrors.Errorf("Value in field \"list\" was too long") } @@ -4350,7 +4352,7 @@ func (t *GraphListitem) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.List)) > cbg.MaxLength { + if len(t.List) > 1000000 { return xerrors.Errorf("Value in field t.List was too long") } @@ -4362,7 +4364,7 @@ func (t *GraphListitem) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -4381,7 +4383,7 @@ func (t *GraphListitem) MarshalCBOR(w io.Writer) error { } // t.Subject (string) (string) - if uint64(len("subject")) > cbg.MaxLength { + if len("subject") > 1000000 { return xerrors.Errorf("Value in field \"subject\" was too long") } @@ -4392,7 +4394,7 @@ func (t *GraphListitem) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Subject)) > cbg.MaxLength { + if len(t.Subject) > 1000000 { return xerrors.Errorf("Value in field t.Subject was too long") } @@ -4404,7 +4406,7 @@ func (t *GraphListitem) MarshalCBOR(w io.Writer) error { } // t.CreatedAt (string) (string) - if uint64(len("createdAt")) > cbg.MaxLength { + if len("createdAt") > 1000000 { return xerrors.Errorf("Value in field \"createdAt\" was too long") } @@ -4415,7 +4417,7 @@ func (t *GraphListitem) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.CreatedAt)) > cbg.MaxLength { + if len(t.CreatedAt) > 1000000 { return xerrors.Errorf("Value in field t.CreatedAt was too long") } @@ -4457,7 +4459,7 @@ func (t *GraphListitem) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -4470,7 +4472,7 @@ func (t *GraphListitem) UnmarshalCBOR(r io.Reader) (err error) { case "list": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -4481,7 +4483,7 @@ func (t *GraphListitem) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -4492,7 +4494,7 @@ func (t *GraphListitem) UnmarshalCBOR(r io.Reader) (err error) { case "subject": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -4503,7 +4505,7 @@ func (t *GraphListitem) UnmarshalCBOR(r io.Reader) (err error) { case "createdAt": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -4549,7 +4551,7 @@ func (t *FeedGenerator) MarshalCBOR(w io.Writer) error { } // t.Did (string) (string) - if uint64(len("did")) > cbg.MaxLength { + if len("did") > 1000000 { return xerrors.Errorf("Value in field \"did\" was too long") } @@ -4560,7 +4562,7 @@ func (t *FeedGenerator) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Did)) > cbg.MaxLength { + if len(t.Did) > 1000000 { return xerrors.Errorf("Value in field t.Did was too long") } @@ -4572,7 +4574,7 @@ func (t *FeedGenerator) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -4593,7 +4595,7 @@ func (t *FeedGenerator) MarshalCBOR(w io.Writer) error { // t.Avatar (util.LexBlob) (struct) if t.Avatar != nil { - if uint64(len("avatar")) > cbg.MaxLength { + if len("avatar") > 1000000 { return xerrors.Errorf("Value in field \"avatar\" was too long") } @@ -4612,7 +4614,7 @@ func (t *FeedGenerator) MarshalCBOR(w io.Writer) error { // t.Labels (bsky.FeedGenerator_Labels) (struct) if t.Labels != nil { - if uint64(len("labels")) > cbg.MaxLength { + if len("labels") > 1000000 { return xerrors.Errorf("Value in field \"labels\" was too long") } @@ -4629,7 +4631,7 @@ func (t *FeedGenerator) MarshalCBOR(w io.Writer) error { } // t.CreatedAt (string) (string) - if uint64(len("createdAt")) > cbg.MaxLength { + if len("createdAt") > 1000000 { return xerrors.Errorf("Value in field \"createdAt\" was too long") } @@ -4640,7 +4642,7 @@ func (t *FeedGenerator) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.CreatedAt)) > cbg.MaxLength { + if len(t.CreatedAt) > 1000000 { return xerrors.Errorf("Value in field t.CreatedAt was too long") } @@ -4654,7 +4656,7 @@ func (t *FeedGenerator) MarshalCBOR(w io.Writer) error { // t.Description (string) (string) if t.Description != nil { - if uint64(len("description")) > cbg.MaxLength { + if len("description") > 1000000 { return xerrors.Errorf("Value in field \"description\" was too long") } @@ -4670,7 +4672,7 @@ func (t *FeedGenerator) MarshalCBOR(w io.Writer) error { return err } } else { - if uint64(len(*t.Description)) > cbg.MaxLength { + if len(*t.Description) > 1000000 { return xerrors.Errorf("Value in field t.Description was too long") } @@ -4684,7 +4686,7 @@ func (t *FeedGenerator) MarshalCBOR(w io.Writer) error { } // t.DisplayName (string) (string) - if uint64(len("displayName")) > cbg.MaxLength { + if len("displayName") > 1000000 { return xerrors.Errorf("Value in field \"displayName\" was too long") } @@ -4695,7 +4697,7 @@ func (t *FeedGenerator) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.DisplayName)) > cbg.MaxLength { + if len(t.DisplayName) > 1000000 { return xerrors.Errorf("Value in field t.DisplayName was too long") } @@ -4709,7 +4711,7 @@ func (t *FeedGenerator) MarshalCBOR(w io.Writer) error { // t.DescriptionFacets ([]*bsky.RichtextFacet) (slice) if t.DescriptionFacets != nil { - if uint64(len("descriptionFacets")) > cbg.MaxLength { + if len("descriptionFacets") > 1000000 { return xerrors.Errorf("Value in field \"descriptionFacets\" was too long") } @@ -4720,7 +4722,7 @@ func (t *FeedGenerator) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.DescriptionFacets)) > cbg.MaxLength { + if len(t.DescriptionFacets) > 8192 { return xerrors.Errorf("Slice value in field t.DescriptionFacets was too long") } @@ -4766,7 +4768,7 @@ func (t *FeedGenerator) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -4779,7 +4781,7 @@ func (t *FeedGenerator) UnmarshalCBOR(r io.Reader) (err error) { case "did": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -4790,7 +4792,7 @@ func (t *FeedGenerator) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -4841,7 +4843,7 @@ func (t *FeedGenerator) UnmarshalCBOR(r io.Reader) (err error) { case "createdAt": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -4861,7 +4863,7 @@ func (t *FeedGenerator) UnmarshalCBOR(r io.Reader) (err error) { return err } - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -4873,7 +4875,7 @@ func (t *FeedGenerator) UnmarshalCBOR(r io.Reader) (err error) { case "displayName": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -4888,7 +4890,7 @@ func (t *FeedGenerator) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.DescriptionFacets: array too large (%d)", extra) } @@ -4951,7 +4953,7 @@ func (t *GraphListblock) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -4970,7 +4972,7 @@ func (t *GraphListblock) MarshalCBOR(w io.Writer) error { } // t.Subject (string) (string) - if uint64(len("subject")) > cbg.MaxLength { + if len("subject") > 1000000 { return xerrors.Errorf("Value in field \"subject\" was too long") } @@ -4981,7 +4983,7 @@ func (t *GraphListblock) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Subject)) > cbg.MaxLength { + if len(t.Subject) > 1000000 { return xerrors.Errorf("Value in field t.Subject was too long") } @@ -4993,7 +4995,7 @@ func (t *GraphListblock) MarshalCBOR(w io.Writer) error { } // t.CreatedAt (string) (string) - if uint64(len("createdAt")) > cbg.MaxLength { + if len("createdAt") > 1000000 { return xerrors.Errorf("Value in field \"createdAt\" was too long") } @@ -5004,7 +5006,7 @@ func (t *GraphListblock) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.CreatedAt)) > cbg.MaxLength { + if len(t.CreatedAt) > 1000000 { return xerrors.Errorf("Value in field t.CreatedAt was too long") } @@ -5046,7 +5048,7 @@ func (t *GraphListblock) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -5059,7 +5061,7 @@ func (t *GraphListblock) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -5070,7 +5072,7 @@ func (t *GraphListblock) UnmarshalCBOR(r io.Reader) (err error) { case "subject": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -5081,7 +5083,7 @@ func (t *GraphListblock) UnmarshalCBOR(r io.Reader) (err error) { case "createdAt": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -5110,7 +5112,7 @@ func (t *EmbedImages_AspectRatio) MarshalCBOR(w io.Writer) error { } // t.Width (int64) (int64) - if uint64(len("width")) > cbg.MaxLength { + if len("width") > 1000000 { return xerrors.Errorf("Value in field \"width\" was too long") } @@ -5132,7 +5134,7 @@ func (t *EmbedImages_AspectRatio) MarshalCBOR(w io.Writer) error { } // t.Height (int64) (int64) - if uint64(len("height")) > cbg.MaxLength { + if len("height") > 1000000 { return xerrors.Errorf("Value in field \"height\" was too long") } @@ -5152,6 +5154,7 @@ func (t *EmbedImages_AspectRatio) MarshalCBOR(w io.Writer) error { return err } } + return nil } @@ -5184,7 +5187,7 @@ func (t *EmbedImages_AspectRatio) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -5197,10 +5200,10 @@ func (t *EmbedImages_AspectRatio) UnmarshalCBOR(r io.Reader) (err error) { case "width": { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -5223,10 +5226,10 @@ func (t *EmbedImages_AspectRatio) UnmarshalCBOR(r io.Reader) (err error) { case "height": { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -5272,7 +5275,7 @@ func (t *FeedThreadgate) MarshalCBOR(w io.Writer) error { } // t.Post (string) (string) - if uint64(len("post")) > cbg.MaxLength { + if len("post") > 1000000 { return xerrors.Errorf("Value in field \"post\" was too long") } @@ -5283,7 +5286,7 @@ func (t *FeedThreadgate) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Post)) > cbg.MaxLength { + if len(t.Post) > 1000000 { return xerrors.Errorf("Value in field t.Post was too long") } @@ -5295,7 +5298,7 @@ func (t *FeedThreadgate) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -5316,7 +5319,7 @@ func (t *FeedThreadgate) MarshalCBOR(w io.Writer) error { // t.Allow ([]*bsky.FeedThreadgate_Allow_Elem) (slice) if t.Allow != nil { - if uint64(len("allow")) > cbg.MaxLength { + if len("allow") > 1000000 { return xerrors.Errorf("Value in field \"allow\" was too long") } @@ -5327,7 +5330,7 @@ func (t *FeedThreadgate) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Allow)) > cbg.MaxLength { + if len(t.Allow) > 8192 { return xerrors.Errorf("Slice value in field t.Allow was too long") } @@ -5343,7 +5346,7 @@ func (t *FeedThreadgate) MarshalCBOR(w io.Writer) error { } // t.CreatedAt (string) (string) - if uint64(len("createdAt")) > cbg.MaxLength { + if len("createdAt") > 1000000 { return xerrors.Errorf("Value in field \"createdAt\" was too long") } @@ -5354,7 +5357,7 @@ func (t *FeedThreadgate) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.CreatedAt)) > cbg.MaxLength { + if len(t.CreatedAt) > 1000000 { return xerrors.Errorf("Value in field t.CreatedAt was too long") } @@ -5396,7 +5399,7 @@ func (t *FeedThreadgate) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -5409,7 +5412,7 @@ func (t *FeedThreadgate) UnmarshalCBOR(r io.Reader) (err error) { case "post": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -5420,7 +5423,7 @@ func (t *FeedThreadgate) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -5435,7 +5438,7 @@ func (t *FeedThreadgate) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.Allow: array too large (%d)", extra) } @@ -5480,7 +5483,7 @@ func (t *FeedThreadgate) UnmarshalCBOR(r io.Reader) (err error) { case "createdAt": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -5509,7 +5512,7 @@ func (t *FeedThreadgate_ListRule) MarshalCBOR(w io.Writer) error { } // t.List (string) (string) - if uint64(len("list")) > cbg.MaxLength { + if len("list") > 1000000 { return xerrors.Errorf("Value in field \"list\" was too long") } @@ -5520,7 +5523,7 @@ func (t *FeedThreadgate_ListRule) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.List)) > cbg.MaxLength { + if len(t.List) > 1000000 { return xerrors.Errorf("Value in field t.List was too long") } @@ -5532,7 +5535,7 @@ func (t *FeedThreadgate_ListRule) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -5581,7 +5584,7 @@ func (t *FeedThreadgate_ListRule) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -5594,7 +5597,7 @@ func (t *FeedThreadgate_ListRule) UnmarshalCBOR(r io.Reader) (err error) { case "list": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -5605,7 +5608,7 @@ func (t *FeedThreadgate_ListRule) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -5634,7 +5637,7 @@ func (t *FeedThreadgate_MentionRule) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -5683,7 +5686,7 @@ func (t *FeedThreadgate_MentionRule) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -5696,7 +5699,7 @@ func (t *FeedThreadgate_MentionRule) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -5725,7 +5728,7 @@ func (t *FeedThreadgate_FollowingRule) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -5774,7 +5777,7 @@ func (t *FeedThreadgate_FollowingRule) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -5787,7 +5790,7 @@ func (t *FeedThreadgate_FollowingRule) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -5821,7 +5824,7 @@ func (t *LabelerService) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -5842,7 +5845,7 @@ func (t *LabelerService) MarshalCBOR(w io.Writer) error { // t.Labels (bsky.LabelerService_Labels) (struct) if t.Labels != nil { - if uint64(len("labels")) > cbg.MaxLength { + if len("labels") > 1000000 { return xerrors.Errorf("Value in field \"labels\" was too long") } @@ -5859,7 +5862,7 @@ func (t *LabelerService) MarshalCBOR(w io.Writer) error { } // t.Policies (bsky.LabelerDefs_LabelerPolicies) (struct) - if uint64(len("policies")) > cbg.MaxLength { + if len("policies") > 1000000 { return xerrors.Errorf("Value in field \"policies\" was too long") } @@ -5875,7 +5878,7 @@ func (t *LabelerService) MarshalCBOR(w io.Writer) error { } // t.CreatedAt (string) (string) - if uint64(len("createdAt")) > cbg.MaxLength { + if len("createdAt") > 1000000 { return xerrors.Errorf("Value in field \"createdAt\" was too long") } @@ -5886,7 +5889,7 @@ func (t *LabelerService) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.CreatedAt)) > cbg.MaxLength { + if len(t.CreatedAt) > 1000000 { return xerrors.Errorf("Value in field t.CreatedAt was too long") } @@ -5928,7 +5931,7 @@ func (t *LabelerService) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -5941,7 +5944,7 @@ func (t *LabelerService) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -5992,7 +5995,7 @@ func (t *LabelerService) UnmarshalCBOR(r io.Reader) (err error) { case "createdAt": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -6026,7 +6029,7 @@ func (t *LabelerDefs_LabelerPolicies) MarshalCBOR(w io.Writer) error { } // t.LabelValues ([]*string) (slice) - if uint64(len("labelValues")) > cbg.MaxLength { + if len("labelValues") > 1000000 { return xerrors.Errorf("Value in field \"labelValues\" was too long") } @@ -6037,7 +6040,7 @@ func (t *LabelerDefs_LabelerPolicies) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.LabelValues)) > cbg.MaxLength { + if len(t.LabelValues) > 8192 { return xerrors.Errorf("Slice value in field t.LabelValues was too long") } @@ -6050,7 +6053,7 @@ func (t *LabelerDefs_LabelerPolicies) MarshalCBOR(w io.Writer) error { return err } } else { - if uint64(len(*v)) > cbg.MaxLength { + if len(*v) > 1000000 { return xerrors.Errorf("Value in field v was too long") } @@ -6067,7 +6070,7 @@ func (t *LabelerDefs_LabelerPolicies) MarshalCBOR(w io.Writer) error { // t.LabelValueDefinitions ([]*atproto.LabelDefs_LabelValueDefinition) (slice) if t.LabelValueDefinitions != nil { - if uint64(len("labelValueDefinitions")) > cbg.MaxLength { + if len("labelValueDefinitions") > 1000000 { return xerrors.Errorf("Value in field \"labelValueDefinitions\" was too long") } @@ -6078,7 +6081,7 @@ func (t *LabelerDefs_LabelerPolicies) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.LabelValueDefinitions)) > cbg.MaxLength { + if len(t.LabelValueDefinitions) > 8192 { return xerrors.Errorf("Slice value in field t.LabelValueDefinitions was too long") } @@ -6124,7 +6127,7 @@ func (t *LabelerDefs_LabelerPolicies) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -6141,7 +6144,7 @@ func (t *LabelerDefs_LabelerPolicies) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.LabelValues: array too large (%d)", extra) } @@ -6163,7 +6166,7 @@ func (t *LabelerDefs_LabelerPolicies) UnmarshalCBOR(r io.Reader) (err error) { _ = err { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -6181,7 +6184,7 @@ func (t *LabelerDefs_LabelerPolicies) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.LabelValueDefinitions: array too large (%d)", extra) } diff --git a/api/cbor_gen.go b/api/cbor_gen.go index 7585e766..66b989ef 100644 --- a/api/cbor_gen.go +++ b/api/cbor_gen.go @@ -38,7 +38,7 @@ func (t *CreateOp) MarshalCBOR(w io.Writer) error { // t.Sig (string) (string) if t.Sig != "" { - if uint64(len("sig")) > cbg.MaxLength { + if len("sig") > 1000000 { return xerrors.Errorf("Value in field \"sig\" was too long") } @@ -49,7 +49,7 @@ func (t *CreateOp) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Sig)) > cbg.MaxLength { + if len(t.Sig) > 1000000 { return xerrors.Errorf("Value in field t.Sig was too long") } @@ -62,7 +62,7 @@ func (t *CreateOp) MarshalCBOR(w io.Writer) error { } // t.Prev (string) (string) - if uint64(len("prev")) > cbg.MaxLength { + if len("prev") > 1000000 { return xerrors.Errorf("Value in field \"prev\" was too long") } @@ -78,7 +78,7 @@ func (t *CreateOp) MarshalCBOR(w io.Writer) error { return err } } else { - if uint64(len(*t.Prev)) > cbg.MaxLength { + if len(*t.Prev) > 1000000 { return xerrors.Errorf("Value in field t.Prev was too long") } @@ -91,7 +91,7 @@ func (t *CreateOp) MarshalCBOR(w io.Writer) error { } // t.Type (string) (string) - if uint64(len("type")) > cbg.MaxLength { + if len("type") > 1000000 { return xerrors.Errorf("Value in field \"type\" was too long") } @@ -102,7 +102,7 @@ func (t *CreateOp) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Type)) > cbg.MaxLength { + if len(t.Type) > 1000000 { return xerrors.Errorf("Value in field t.Type was too long") } @@ -114,7 +114,7 @@ func (t *CreateOp) MarshalCBOR(w io.Writer) error { } // t.Handle (string) (string) - if uint64(len("handle")) > cbg.MaxLength { + if len("handle") > 1000000 { return xerrors.Errorf("Value in field \"handle\" was too long") } @@ -125,7 +125,7 @@ func (t *CreateOp) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Handle)) > cbg.MaxLength { + if len(t.Handle) > 1000000 { return xerrors.Errorf("Value in field t.Handle was too long") } @@ -137,7 +137,7 @@ func (t *CreateOp) MarshalCBOR(w io.Writer) error { } // t.Service (string) (string) - if uint64(len("service")) > cbg.MaxLength { + if len("service") > 1000000 { return xerrors.Errorf("Value in field \"service\" was too long") } @@ -148,7 +148,7 @@ func (t *CreateOp) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Service)) > cbg.MaxLength { + if len(t.Service) > 1000000 { return xerrors.Errorf("Value in field t.Service was too long") } @@ -160,7 +160,7 @@ func (t *CreateOp) MarshalCBOR(w io.Writer) error { } // t.SigningKey (string) (string) - if uint64(len("signingKey")) > cbg.MaxLength { + if len("signingKey") > 1000000 { return xerrors.Errorf("Value in field \"signingKey\" was too long") } @@ -171,7 +171,7 @@ func (t *CreateOp) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.SigningKey)) > cbg.MaxLength { + if len(t.SigningKey) > 1000000 { return xerrors.Errorf("Value in field t.SigningKey was too long") } @@ -183,7 +183,7 @@ func (t *CreateOp) MarshalCBOR(w io.Writer) error { } // t.RecoveryKey (string) (string) - if uint64(len("recoveryKey")) > cbg.MaxLength { + if len("recoveryKey") > 1000000 { return xerrors.Errorf("Value in field \"recoveryKey\" was too long") } @@ -194,7 +194,7 @@ func (t *CreateOp) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.RecoveryKey)) > cbg.MaxLength { + if len(t.RecoveryKey) > 1000000 { return xerrors.Errorf("Value in field t.RecoveryKey was too long") } @@ -236,7 +236,7 @@ func (t *CreateOp) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -249,7 +249,7 @@ func (t *CreateOp) UnmarshalCBOR(r io.Reader) (err error) { case "sig": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -269,7 +269,7 @@ func (t *CreateOp) UnmarshalCBOR(r io.Reader) (err error) { return err } - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -281,7 +281,7 @@ func (t *CreateOp) UnmarshalCBOR(r io.Reader) (err error) { case "type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -292,7 +292,7 @@ func (t *CreateOp) UnmarshalCBOR(r io.Reader) (err error) { case "handle": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -303,7 +303,7 @@ func (t *CreateOp) UnmarshalCBOR(r io.Reader) (err error) { case "service": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -314,7 +314,7 @@ func (t *CreateOp) UnmarshalCBOR(r io.Reader) (err error) { case "signingKey": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -325,7 +325,7 @@ func (t *CreateOp) UnmarshalCBOR(r io.Reader) (err error) { case "recoveryKey": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } diff --git a/atproto/data/cbor_gen.go b/atproto/data/cbor_gen.go index da7364c1..89c5e0a5 100644 --- a/atproto/data/cbor_gen.go +++ b/atproto/data/cbor_gen.go @@ -31,7 +31,7 @@ func (t *GenericRecord) MarshalCBOR(w io.Writer) error { } // t.Type (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -42,7 +42,7 @@ func (t *GenericRecord) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Type)) > cbg.MaxLength { + if len(t.Type) > 1000000 { return xerrors.Errorf("Value in field t.Type was too long") } @@ -84,7 +84,7 @@ func (t *GenericRecord) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -97,7 +97,7 @@ func (t *GenericRecord) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -126,7 +126,7 @@ func (t *LegacyBlobSchema) MarshalCBOR(w io.Writer) error { } // t.Cid (string) (string) - if uint64(len("cid")) > cbg.MaxLength { + if len("cid") > 1000000 { return xerrors.Errorf("Value in field \"cid\" was too long") } @@ -137,7 +137,7 @@ func (t *LegacyBlobSchema) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Cid)) > cbg.MaxLength { + if len(t.Cid) > 1000000 { return xerrors.Errorf("Value in field t.Cid was too long") } @@ -149,7 +149,7 @@ func (t *LegacyBlobSchema) MarshalCBOR(w io.Writer) error { } // t.MimeType (string) (string) - if uint64(len("mimeType")) > cbg.MaxLength { + if len("mimeType") > 1000000 { return xerrors.Errorf("Value in field \"mimeType\" was too long") } @@ -160,7 +160,7 @@ func (t *LegacyBlobSchema) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.MimeType)) > cbg.MaxLength { + if len(t.MimeType) > 1000000 { return xerrors.Errorf("Value in field t.MimeType was too long") } @@ -202,7 +202,7 @@ func (t *LegacyBlobSchema) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -215,7 +215,7 @@ func (t *LegacyBlobSchema) UnmarshalCBOR(r io.Reader) (err error) { case "cid": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -226,7 +226,7 @@ func (t *LegacyBlobSchema) UnmarshalCBOR(r io.Reader) (err error) { case "mimeType": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -255,7 +255,7 @@ func (t *BlobSchema) MarshalCBOR(w io.Writer) error { } // t.Ref (data.CIDLink) (struct) - if uint64(len("ref")) > cbg.MaxLength { + if len("ref") > 1000000 { return xerrors.Errorf("Value in field \"ref\" was too long") } @@ -271,7 +271,7 @@ func (t *BlobSchema) MarshalCBOR(w io.Writer) error { } // t.Size (int64) (int64) - if uint64(len("size")) > cbg.MaxLength { + if len("size") > 1000000 { return xerrors.Errorf("Value in field \"size\" was too long") } @@ -293,7 +293,7 @@ func (t *BlobSchema) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -312,7 +312,7 @@ func (t *BlobSchema) MarshalCBOR(w io.Writer) error { } // t.MimeType (string) (string) - if uint64(len("mimeType")) > cbg.MaxLength { + if len("mimeType") > 1000000 { return xerrors.Errorf("Value in field \"mimeType\" was too long") } @@ -323,7 +323,7 @@ func (t *BlobSchema) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.MimeType)) > cbg.MaxLength { + if len(t.MimeType) > 1000000 { return xerrors.Errorf("Value in field t.MimeType was too long") } @@ -365,7 +365,7 @@ func (t *BlobSchema) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -388,10 +388,10 @@ func (t *BlobSchema) UnmarshalCBOR(r io.Reader) (err error) { case "size": { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -414,7 +414,7 @@ func (t *BlobSchema) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -425,7 +425,7 @@ func (t *BlobSchema) UnmarshalCBOR(r io.Reader) (err error) { case "mimeType": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } diff --git a/events/cbor_gen.go b/events/cbor_gen.go index 98af90b6..efb87344 100644 --- a/events/cbor_gen.go +++ b/events/cbor_gen.go @@ -31,7 +31,7 @@ func (t *EventHeader) MarshalCBOR(w io.Writer) error { } // t.MsgType (string) (string) - if uint64(len("t")) > cbg.MaxLength { + if len("t") > 1000000 { return xerrors.Errorf("Value in field \"t\" was too long") } @@ -42,7 +42,7 @@ func (t *EventHeader) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.MsgType)) > cbg.MaxLength { + if len(t.MsgType) > 1000000 { return xerrors.Errorf("Value in field t.MsgType was too long") } @@ -54,7 +54,7 @@ func (t *EventHeader) MarshalCBOR(w io.Writer) error { } // t.Op (int64) (int64) - if uint64(len("op")) > cbg.MaxLength { + if len("op") > 1000000 { return xerrors.Errorf("Value in field \"op\" was too long") } @@ -74,6 +74,7 @@ func (t *EventHeader) MarshalCBOR(w io.Writer) error { return err } } + return nil } @@ -106,7 +107,7 @@ func (t *EventHeader) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -119,7 +120,7 @@ func (t *EventHeader) UnmarshalCBOR(r io.Reader) (err error) { case "t": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -130,10 +131,10 @@ func (t *EventHeader) UnmarshalCBOR(r io.Reader) (err error) { case "op": { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -174,7 +175,7 @@ func (t *ErrorFrame) MarshalCBOR(w io.Writer) error { } // t.Error (string) (string) - if uint64(len("error")) > cbg.MaxLength { + if len("error") > 1000000 { return xerrors.Errorf("Value in field \"error\" was too long") } @@ -185,7 +186,7 @@ func (t *ErrorFrame) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Error)) > cbg.MaxLength { + if len(t.Error) > 1000000 { return xerrors.Errorf("Value in field t.Error was too long") } @@ -197,7 +198,7 @@ func (t *ErrorFrame) MarshalCBOR(w io.Writer) error { } // t.Message (string) (string) - if uint64(len("message")) > cbg.MaxLength { + if len("message") > 1000000 { return xerrors.Errorf("Value in field \"message\" was too long") } @@ -208,7 +209,7 @@ func (t *ErrorFrame) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Message)) > cbg.MaxLength { + if len(t.Message) > 1000000 { return xerrors.Errorf("Value in field t.Message was too long") } @@ -250,7 +251,7 @@ func (t *ErrorFrame) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -263,7 +264,7 @@ func (t *ErrorFrame) UnmarshalCBOR(r io.Reader) (err error) { case "error": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -274,7 +275,7 @@ func (t *ErrorFrame) UnmarshalCBOR(r io.Reader) (err error) { case "message": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } diff --git a/lex/util/cbor_gen.go b/lex/util/cbor_gen.go index cb187be0..dd057f1f 100644 --- a/lex/util/cbor_gen.go +++ b/lex/util/cbor_gen.go @@ -31,7 +31,7 @@ func (t *CborChecker) MarshalCBOR(w io.Writer) error { } // t.Type (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -42,7 +42,7 @@ func (t *CborChecker) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Type)) > cbg.MaxLength { + if len(t.Type) > 1000000 { return xerrors.Errorf("Value in field t.Type was too long") } @@ -84,7 +84,7 @@ func (t *CborChecker) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -97,7 +97,7 @@ func (t *CborChecker) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -126,7 +126,7 @@ func (t *LegacyBlob) MarshalCBOR(w io.Writer) error { } // t.Cid (string) (string) - if uint64(len("cid")) > cbg.MaxLength { + if len("cid") > 1000000 { return xerrors.Errorf("Value in field \"cid\" was too long") } @@ -137,7 +137,7 @@ func (t *LegacyBlob) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Cid)) > cbg.MaxLength { + if len(t.Cid) > 1000000 { return xerrors.Errorf("Value in field t.Cid was too long") } @@ -149,7 +149,7 @@ func (t *LegacyBlob) MarshalCBOR(w io.Writer) error { } // t.MimeType (string) (string) - if uint64(len("mimeType")) > cbg.MaxLength { + if len("mimeType") > 1000000 { return xerrors.Errorf("Value in field \"mimeType\" was too long") } @@ -160,7 +160,7 @@ func (t *LegacyBlob) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.MimeType)) > cbg.MaxLength { + if len(t.MimeType) > 1000000 { return xerrors.Errorf("Value in field t.MimeType was too long") } @@ -202,7 +202,7 @@ func (t *LegacyBlob) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -215,7 +215,7 @@ func (t *LegacyBlob) UnmarshalCBOR(r io.Reader) (err error) { case "cid": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -226,7 +226,7 @@ func (t *LegacyBlob) UnmarshalCBOR(r io.Reader) (err error) { case "mimeType": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -255,7 +255,7 @@ func (t *BlobSchema) MarshalCBOR(w io.Writer) error { } // t.Ref (util.LexLink) (struct) - if uint64(len("ref")) > cbg.MaxLength { + if len("ref") > 1000000 { return xerrors.Errorf("Value in field \"ref\" was too long") } @@ -271,7 +271,7 @@ func (t *BlobSchema) MarshalCBOR(w io.Writer) error { } // t.Size (int64) (int64) - if uint64(len("size")) > cbg.MaxLength { + if len("size") > 1000000 { return xerrors.Errorf("Value in field \"size\" was too long") } @@ -293,7 +293,7 @@ func (t *BlobSchema) MarshalCBOR(w io.Writer) error { } // t.LexiconTypeID (string) (string) - if uint64(len("$type")) > cbg.MaxLength { + if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } @@ -312,7 +312,7 @@ func (t *BlobSchema) MarshalCBOR(w io.Writer) error { } // t.MimeType (string) (string) - if uint64(len("mimeType")) > cbg.MaxLength { + if len("mimeType") > 1000000 { return xerrors.Errorf("Value in field \"mimeType\" was too long") } @@ -323,7 +323,7 @@ func (t *BlobSchema) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.MimeType)) > cbg.MaxLength { + if len(t.MimeType) > 1000000 { return xerrors.Errorf("Value in field t.MimeType was too long") } @@ -365,7 +365,7 @@ func (t *BlobSchema) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -388,10 +388,10 @@ func (t *BlobSchema) UnmarshalCBOR(r io.Reader) (err error) { case "size": { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -414,7 +414,7 @@ func (t *BlobSchema) UnmarshalCBOR(r io.Reader) (err error) { case "$type": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -425,7 +425,7 @@ func (t *BlobSchema) UnmarshalCBOR(r io.Reader) (err error) { case "mimeType": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } diff --git a/mst/cbor_gen.go b/mst/cbor_gen.go index 702aac3d..19dd2f75 100644 --- a/mst/cbor_gen.go +++ b/mst/cbor_gen.go @@ -31,7 +31,7 @@ func (t *nodeData) MarshalCBOR(w io.Writer) error { } // t.Entries ([]mst.treeEntry) (slice) - if uint64(len("e")) > cbg.MaxLength { + if len("e") > 1000000 { return xerrors.Errorf("Value in field \"e\" was too long") } @@ -42,7 +42,7 @@ func (t *nodeData) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Entries)) > cbg.MaxLength { + if len(t.Entries) > 8192 { return xerrors.Errorf("Slice value in field t.Entries was too long") } @@ -57,7 +57,7 @@ func (t *nodeData) MarshalCBOR(w io.Writer) error { } // t.Left (cid.Cid) (struct) - if uint64(len("l")) > cbg.MaxLength { + if len("l") > 1000000 { return xerrors.Errorf("Value in field \"l\" was too long") } @@ -110,7 +110,7 @@ func (t *nodeData) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -127,7 +127,7 @@ func (t *nodeData) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 8192 { return fmt.Errorf("t.Entries: array too large (%d)", extra) } @@ -203,7 +203,7 @@ func (t *treeEntry) MarshalCBOR(w io.Writer) error { } // t.KeySuffix ([]uint8) (slice) - if uint64(len("k")) > cbg.MaxLength { + if len("k") > 1000000 { return xerrors.Errorf("Value in field \"k\" was too long") } @@ -214,7 +214,7 @@ func (t *treeEntry) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.KeySuffix)) > cbg.ByteArrayMaxLen { + if len(t.KeySuffix) > 2097152 { return xerrors.Errorf("Byte array in field t.KeySuffix was too long") } @@ -227,7 +227,7 @@ func (t *treeEntry) MarshalCBOR(w io.Writer) error { } // t.PrefixLen (int64) (int64) - if uint64(len("p")) > cbg.MaxLength { + if len("p") > 1000000 { return xerrors.Errorf("Value in field \"p\" was too long") } @@ -249,7 +249,7 @@ func (t *treeEntry) MarshalCBOR(w io.Writer) error { } // t.Tree (cid.Cid) (struct) - if uint64(len("t")) > cbg.MaxLength { + if len("t") > 1000000 { return xerrors.Errorf("Value in field \"t\" was too long") } @@ -271,7 +271,7 @@ func (t *treeEntry) MarshalCBOR(w io.Writer) error { } // t.Val (cid.Cid) (struct) - if uint64(len("v")) > cbg.MaxLength { + if len("v") > 1000000 { return xerrors.Errorf("Value in field \"v\" was too long") } @@ -318,7 +318,7 @@ func (t *treeEntry) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -335,7 +335,7 @@ func (t *treeEntry) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.ByteArrayMaxLen { + if extra > 2097152 { return fmt.Errorf("t.KeySuffix: byte array too large (%d)", extra) } if maj != cbg.MajByteString { @@ -354,10 +354,10 @@ func (t *treeEntry) UnmarshalCBOR(r io.Reader) (err error) { case "p": { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) diff --git a/repo/cbor_gen.go b/repo/cbor_gen.go index 5576ff0b..96bfb2e0 100644 --- a/repo/cbor_gen.go +++ b/repo/cbor_gen.go @@ -36,7 +36,7 @@ func (t *SignedCommit) MarshalCBOR(w io.Writer) error { } // t.Did (string) (string) - if uint64(len("did")) > cbg.MaxLength { + if len("did") > 1000000 { return xerrors.Errorf("Value in field \"did\" was too long") } @@ -47,7 +47,7 @@ func (t *SignedCommit) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Did)) > cbg.MaxLength { + if len(t.Did) > 1000000 { return xerrors.Errorf("Value in field t.Did was too long") } @@ -61,7 +61,7 @@ func (t *SignedCommit) MarshalCBOR(w io.Writer) error { // t.Rev (string) (string) if t.Rev != "" { - if uint64(len("rev")) > cbg.MaxLength { + if len("rev") > 1000000 { return xerrors.Errorf("Value in field \"rev\" was too long") } @@ -72,7 +72,7 @@ func (t *SignedCommit) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Rev)) > cbg.MaxLength { + if len(t.Rev) > 1000000 { return xerrors.Errorf("Value in field t.Rev was too long") } @@ -85,7 +85,7 @@ func (t *SignedCommit) MarshalCBOR(w io.Writer) error { } // t.Sig ([]uint8) (slice) - if uint64(len("sig")) > cbg.MaxLength { + if len("sig") > 1000000 { return xerrors.Errorf("Value in field \"sig\" was too long") } @@ -96,7 +96,7 @@ func (t *SignedCommit) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Sig)) > cbg.ByteArrayMaxLen { + if len(t.Sig) > 2097152 { return xerrors.Errorf("Byte array in field t.Sig was too long") } @@ -109,7 +109,7 @@ func (t *SignedCommit) MarshalCBOR(w io.Writer) error { } // t.Data (cid.Cid) (struct) - if uint64(len("data")) > cbg.MaxLength { + if len("data") > 1000000 { return xerrors.Errorf("Value in field \"data\" was too long") } @@ -125,7 +125,7 @@ func (t *SignedCommit) MarshalCBOR(w io.Writer) error { } // t.Prev (cid.Cid) (struct) - if uint64(len("prev")) > cbg.MaxLength { + if len("prev") > 1000000 { return xerrors.Errorf("Value in field \"prev\" was too long") } @@ -147,7 +147,7 @@ func (t *SignedCommit) MarshalCBOR(w io.Writer) error { } // t.Version (int64) (int64) - if uint64(len("version")) > cbg.MaxLength { + if len("version") > 1000000 { return xerrors.Errorf("Value in field \"version\" was too long") } @@ -167,6 +167,7 @@ func (t *SignedCommit) MarshalCBOR(w io.Writer) error { return err } } + return nil } @@ -199,7 +200,7 @@ func (t *SignedCommit) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -212,7 +213,7 @@ func (t *SignedCommit) UnmarshalCBOR(r io.Reader) (err error) { case "did": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -223,7 +224,7 @@ func (t *SignedCommit) UnmarshalCBOR(r io.Reader) (err error) { case "rev": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -238,7 +239,7 @@ func (t *SignedCommit) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.ByteArrayMaxLen { + if extra > 2097152 { return fmt.Errorf("t.Sig: byte array too large (%d)", extra) } if maj != cbg.MajByteString { @@ -293,10 +294,10 @@ func (t *SignedCommit) UnmarshalCBOR(r io.Reader) (err error) { case "version": { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) @@ -342,7 +343,7 @@ func (t *UnsignedCommit) MarshalCBOR(w io.Writer) error { } // t.Did (string) (string) - if uint64(len("did")) > cbg.MaxLength { + if len("did") > 1000000 { return xerrors.Errorf("Value in field \"did\" was too long") } @@ -353,7 +354,7 @@ func (t *UnsignedCommit) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Did)) > cbg.MaxLength { + if len(t.Did) > 1000000 { return xerrors.Errorf("Value in field t.Did was too long") } @@ -367,7 +368,7 @@ func (t *UnsignedCommit) MarshalCBOR(w io.Writer) error { // t.Rev (string) (string) if t.Rev != "" { - if uint64(len("rev")) > cbg.MaxLength { + if len("rev") > 1000000 { return xerrors.Errorf("Value in field \"rev\" was too long") } @@ -378,7 +379,7 @@ func (t *UnsignedCommit) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Rev)) > cbg.MaxLength { + if len(t.Rev) > 1000000 { return xerrors.Errorf("Value in field t.Rev was too long") } @@ -391,7 +392,7 @@ func (t *UnsignedCommit) MarshalCBOR(w io.Writer) error { } // t.Data (cid.Cid) (struct) - if uint64(len("data")) > cbg.MaxLength { + if len("data") > 1000000 { return xerrors.Errorf("Value in field \"data\" was too long") } @@ -407,7 +408,7 @@ func (t *UnsignedCommit) MarshalCBOR(w io.Writer) error { } // t.Prev (cid.Cid) (struct) - if uint64(len("prev")) > cbg.MaxLength { + if len("prev") > 1000000 { return xerrors.Errorf("Value in field \"prev\" was too long") } @@ -429,7 +430,7 @@ func (t *UnsignedCommit) MarshalCBOR(w io.Writer) error { } // t.Version (int64) (int64) - if uint64(len("version")) > cbg.MaxLength { + if len("version") > 1000000 { return xerrors.Errorf("Value in field \"version\" was too long") } @@ -449,6 +450,7 @@ func (t *UnsignedCommit) MarshalCBOR(w io.Writer) error { return err } } + return nil } @@ -481,7 +483,7 @@ func (t *UnsignedCommit) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -494,7 +496,7 @@ func (t *UnsignedCommit) UnmarshalCBOR(r io.Reader) (err error) { case "did": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -505,7 +507,7 @@ func (t *UnsignedCommit) UnmarshalCBOR(r io.Reader) (err error) { case "rev": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -552,10 +554,10 @@ func (t *UnsignedCommit) UnmarshalCBOR(r io.Reader) (err error) { case "version": { maj, extra, err := cr.ReadHeader() - var extraI int64 if err != nil { return err } + var extraI int64 switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) diff --git a/util/labels/cbor_gen.go b/util/labels/cbor_gen.go index 9ff52f5f..e777d7e4 100644 --- a/util/labels/cbor_gen.go +++ b/util/labels/cbor_gen.go @@ -25,9 +25,13 @@ func (t *UnsignedLabel) MarshalCBOR(w io.Writer) error { } cw := cbg.NewCborWriter(w) - fieldCount := 6 + fieldCount := 8 - if t.CID == nil { + if t.Cid == nil { + fieldCount-- + } + + if t.Exp == nil { fieldCount-- } @@ -35,14 +39,18 @@ func (t *UnsignedLabel) MarshalCBOR(w io.Writer) error { fieldCount-- } + if t.Ver == nil { + fieldCount-- + } + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { return err } - // t.CID (string) (string) - if t.CID != nil { + // t.Cid (string) (string) + if t.Cid != nil { - if uint64(len("cid")) > cbg.MaxLength { + if len("cid") > 1000000 { return xerrors.Errorf("Value in field \"cid\" was too long") } @@ -53,26 +61,26 @@ func (t *UnsignedLabel) MarshalCBOR(w io.Writer) error { return err } - if t.CID == nil { + if t.Cid == nil { if _, err := cw.Write(cbg.CborNull); err != nil { return err } } else { - if uint64(len(*t.CID)) > cbg.MaxLength { - return xerrors.Errorf("Value in field t.CID was too long") + if len(*t.Cid) > 1000000 { + return xerrors.Errorf("Value in field t.Cid was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.CID))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Cid))); err != nil { return err } - if _, err := cw.WriteString(string(*t.CID)); err != nil { + if _, err := cw.WriteString(string(*t.Cid)); err != nil { return err } } } - // t.CTS (string) (string) - if uint64(len("cts")) > cbg.MaxLength { + // t.Cts (string) (string) + if len("cts") > 1000000 { return xerrors.Errorf("Value in field \"cts\" was too long") } @@ -83,21 +91,53 @@ func (t *UnsignedLabel) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.CTS)) > cbg.MaxLength { - return xerrors.Errorf("Value in field t.CTS was too long") + if len(t.Cts) > 1000000 { + return xerrors.Errorf("Value in field t.Cts was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CTS))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Cts))); err != nil { return err } - if _, err := cw.WriteString(string(t.CTS)); err != nil { + if _, err := cw.WriteString(string(t.Cts)); err != nil { return err } + // t.Exp (string) (string) + if t.Exp != nil { + + if len("exp") > 1000000 { + return xerrors.Errorf("Value in field \"exp\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("exp"))); err != nil { + return err + } + if _, err := cw.WriteString(string("exp")); err != nil { + return err + } + + if t.Exp == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.Exp) > 1000000 { + return xerrors.Errorf("Value in field t.Exp was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Exp))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.Exp)); err != nil { + return err + } + } + } + // t.Neg (bool) (bool) if t.Neg != nil { - if uint64(len("neg")) > cbg.MaxLength { + if len("neg") > 1000000 { return xerrors.Errorf("Value in field \"neg\" was too long") } @@ -120,7 +160,7 @@ func (t *UnsignedLabel) MarshalCBOR(w io.Writer) error { } // t.Src (string) (string) - if uint64(len("src")) > cbg.MaxLength { + if len("src") > 1000000 { return xerrors.Errorf("Value in field \"src\" was too long") } @@ -131,7 +171,7 @@ func (t *UnsignedLabel) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Src)) > cbg.MaxLength { + if len(t.Src) > 1000000 { return xerrors.Errorf("Value in field t.Src was too long") } @@ -142,8 +182,8 @@ func (t *UnsignedLabel) MarshalCBOR(w io.Writer) error { return err } - // t.URI (string) (string) - if uint64(len("uri")) > cbg.MaxLength { + // t.Uri (string) (string) + if len("uri") > 1000000 { return xerrors.Errorf("Value in field \"uri\" was too long") } @@ -154,19 +194,19 @@ func (t *UnsignedLabel) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.URI)) > cbg.MaxLength { - return xerrors.Errorf("Value in field t.URI was too long") + if len(t.Uri) > 1000000 { + return xerrors.Errorf("Value in field t.Uri was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.URI))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Uri))); err != nil { return err } - if _, err := cw.WriteString(string(t.URI)); err != nil { + if _, err := cw.WriteString(string(t.Uri)); err != nil { return err } // t.Val (string) (string) - if uint64(len("val")) > cbg.MaxLength { + if len("val") > 1000000 { return xerrors.Errorf("Value in field \"val\" was too long") } @@ -177,7 +217,7 @@ func (t *UnsignedLabel) MarshalCBOR(w io.Writer) error { return err } - if uint64(len(t.Val)) > cbg.MaxLength { + if len(t.Val) > 1000000 { return xerrors.Errorf("Value in field t.Val was too long") } @@ -187,6 +227,38 @@ func (t *UnsignedLabel) MarshalCBOR(w io.Writer) error { if _, err := cw.WriteString(string(t.Val)); err != nil { return err } + + // t.Ver (int64) (int64) + if t.Ver != nil { + + if len("ver") > 1000000 { + return xerrors.Errorf("Value in field \"ver\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("ver"))); err != nil { + return err + } + if _, err := cw.WriteString(string("ver")); err != nil { + return err + } + + if t.Ver == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if *t.Ver >= 0 { + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(*t.Ver)); err != nil { + return err + } + } else { + if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-*t.Ver-1)); err != nil { + return err + } + } + } + + } return nil } @@ -219,7 +291,7 @@ func (t *UnsignedLabel) UnmarshalCBOR(r io.Reader) (err error) { for i := uint64(0); i < n; i++ { { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } @@ -228,7 +300,7 @@ func (t *UnsignedLabel) UnmarshalCBOR(r io.Reader) (err error) { } switch name { - // t.CID (string) (string) + // t.Cid (string) (string) case "cid": { @@ -241,24 +313,45 @@ func (t *UnsignedLabel) UnmarshalCBOR(r io.Reader) (err error) { return err } - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } - t.CID = (*string)(&sval) + t.Cid = (*string)(&sval) } } - // t.CTS (string) (string) + // t.Cts (string) (string) case "cts": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } - t.CTS = string(sval) + t.Cts = string(sval) + } + // t.Exp (string) (string) + case "exp": + + { + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Exp = (*string)(&sval) + } } // t.Neg (bool) (bool) case "neg": @@ -297,35 +390,71 @@ func (t *UnsignedLabel) UnmarshalCBOR(r io.Reader) (err error) { case "src": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } t.Src = string(sval) } - // t.URI (string) (string) + // t.Uri (string) (string) case "uri": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } - t.URI = string(sval) + t.Uri = string(sval) } // t.Val (string) (string) case "val": { - sval, err := cbg.ReadString(cr) + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } t.Val = string(sval) } + // t.Ver (int64) (int64) + case "ver": + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + var extraI int64 + switch maj { + case cbg.MajUnsignedInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 positive overflow") + } + case cbg.MajNegativeInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 negative overflow") + } + extraI = -1 - extraI + default: + return fmt.Errorf("wrong type for int64 field: %d", maj) + } + + t.Ver = (*int64)(&extraI) + } + } default: // Field doesn't exist on this type, so ignore it diff --git a/util/labels/labels.go b/util/labels/labels.go index db66e5a6..29d4e3e7 100644 --- a/util/labels/labels.go +++ b/util/labels/labels.go @@ -9,17 +9,21 @@ import ( // UnsignedLabel is a label without the signature so we can validate it type UnsignedLabel struct { // cid: Optionally, CID specifying the specific version of 'uri' resource this label applies to. - CID *string `json:"cid,omitempty" cborgen:"cid,omitempty"` + Cid *string `json:"cid,omitempty" cborgen:"cid,omitempty"` // cts: Timestamp when this label was created. - CTS string `json:"cts" cborgen:"cts"` + Cts string `json:"cts" cborgen:"cts"` + // exp: Timestamp at which this label expires (no longer applies). + Exp *string `json:"exp,omitempty" cborgen:"exp,omitempty"` // neg: If true, this is a negation label, overwriting a previous label. Neg *bool `json:"neg,omitempty" cborgen:"neg,omitempty"` // src: DID of the actor who created this label. Src string `json:"src" cborgen:"src"` // uri: AT URI of the record, repository (account), or other resource that this label applies to. - URI string `json:"uri" cborgen:"uri"` + Uri string `json:"uri" cborgen:"uri"` // val: The short string name of the value or type of this label. Val string `json:"val" cborgen:"val"` + // ver: The AT Protocol version of the label object. + Ver *int64 `json:"ver,omitempty" cborgen:"ver,omitempty"` } // SignedLabel is a label with a signature, this type is generated via lexgen but aliased here for convenience