This commit is contained in:
Łukasz Magiera 2019-12-09 15:41:44 +01:00
parent d5103a7fbd
commit 570d725ce5
7 changed files with 158 additions and 125 deletions

View File

@ -105,7 +105,8 @@ func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.Vouchers: array too large (%d)", extra)
}
@ -244,7 +245,8 @@ func (t *SealedRefs) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.Refs: array too large (%d)", extra)
}

View File

@ -136,10 +136,10 @@ func (t *ExecParams) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Params: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Params: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -611,10 +611,10 @@ func (t *SectorPreCommitInfo) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.CommR: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.CommR: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -638,7 +638,8 @@ func (t *SectorPreCommitInfo) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.DealIDs: array too large (%d)", extra)
}
@ -863,10 +864,10 @@ func (t *SubmitFallbackPoStParams) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Proof: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Proof: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -880,7 +881,8 @@ func (t *SubmitFallbackPoStParams) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.Candidates: array too large (%d)", extra)
}
@ -951,10 +953,10 @@ func (t *PaymentVerifyParams) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Extra: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Extra: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -968,10 +970,10 @@ func (t *PaymentVerifyParams) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Proof: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Proof: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -1106,7 +1108,8 @@ func (t *MultiSigActorState) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.Signers: array too large (%d)", extra)
}
@ -1181,7 +1184,8 @@ func (t *MultiSigActorState) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.Transactions: array too large (%d)", extra)
}
@ -1256,7 +1260,8 @@ func (t *MultiSigConstructorParams) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.Signers: array too large (%d)", extra)
}
@ -1382,10 +1387,10 @@ func (t *MultiSigProposeParams) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Params: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Params: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -1679,10 +1684,10 @@ func (t *MTransaction) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Params: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Params: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -1696,7 +1701,8 @@ func (t *MTransaction) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.Approved: array too large (%d)", extra)
}
@ -2260,10 +2266,10 @@ func (t *PCAUpdateChannelStateParams) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Secret: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Secret: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -2277,10 +2283,10 @@ func (t *PCAUpdateChannelStateParams) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Proof: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Proof: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -2397,7 +2403,8 @@ func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.Vouchers: array too large (%d)", extra)
}
@ -3239,10 +3246,10 @@ func (t *StorageDealProposal) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.PieceRef: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.PieceRef: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -3461,7 +3468,8 @@ func (t *PublishStorageDealsParams) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.Deals: array too large (%d)", extra)
}
@ -3526,7 +3534,8 @@ func (t *PublishStorageDealResponse) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.DealIDs: array too large (%d)", extra)
}
@ -3595,7 +3604,8 @@ func (t *ActivateStorageDealsParams) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.Deals: array too large (%d)", extra)
}
@ -3664,7 +3674,8 @@ func (t *ProcessStorageDealsPaymentParams) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.DealIDs: array too large (%d)", extra)
}
@ -3796,7 +3807,8 @@ func (t *ComputeDataCommitmentParams) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.DealIDs: array too large (%d)", extra)
}
@ -3888,10 +3900,10 @@ func (t *SectorProveCommitInfo) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Proof: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Proof: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -3915,7 +3927,8 @@ func (t *SectorProveCommitInfo) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.DealIDs: array too large (%d)", extra)
}

View File

@ -5,7 +5,7 @@ import (
"io"
"github.com/filecoin-project/lotus/chain/types"
cid "github.com/ipfs/go-cid"
"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
xerrors "golang.org/x/xerrors"
)
@ -66,7 +66,8 @@ func (t *BlockSyncRequest) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.Start: array too large (%d)", extra)
}
@ -163,7 +164,8 @@ func (t *BlockSyncResponse) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.Chain: array too large (%d)", extra)
}
@ -298,7 +300,8 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.Blocks: array too large (%d)", extra)
}
@ -324,7 +327,8 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.BlsMessages: array too large (%d)", extra)
}
@ -350,7 +354,8 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.BlsMsgIncludes: array too large (%d)", extra)
}
@ -370,7 +375,8 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.BlsMsgIncludes[i]: array too large (%d)", extra)
}
@ -403,7 +409,8 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.SecpkMessages: array too large (%d)", extra)
}
@ -429,7 +436,8 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.SecpkMsgIncludes: array too large (%d)", extra)
}
@ -449,7 +457,8 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.SecpkMsgIncludes[i]: array too large (%d)", extra)
}

View File

@ -5,7 +5,7 @@ import (
"io"
"math"
cid "github.com/ipfs/go-cid"
"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
xerrors "golang.org/x/xerrors"
)
@ -153,7 +153,8 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.Parents: array too large (%d)", extra)
}
@ -310,10 +311,10 @@ func (t *Ticket) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.VRFProof: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.VRFProof: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -382,10 +383,10 @@ func (t *EPostProof) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Proof: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Proof: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -399,10 +400,10 @@ func (t *EPostProof) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.PostRand: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.PostRand: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -416,7 +417,8 @@ func (t *EPostProof) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.Candidates: array too large (%d)", extra)
}
@ -489,10 +491,10 @@ func (t *EPostTicket) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Partial: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Partial: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -663,10 +665,10 @@ func (t *Message) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Params: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Params: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -895,10 +897,10 @@ func (t *SignedVoucher) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.SecretPreimage: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.SecretPreimage: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -972,7 +974,8 @@ func (t *SignedVoucher) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.Merges: array too large (%d)", extra)
}
@ -1085,10 +1088,10 @@ func (t *ModVerifyParams) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Data: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Data: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -1315,10 +1318,10 @@ func (t *MessageReceipt) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Return: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Return: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -1416,7 +1419,8 @@ func (t *BlockMsg) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.BlsMessages: array too large (%d)", extra)
}
@ -1441,7 +1445,8 @@ func (t *BlockMsg) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.SecpkMessages: array too large (%d)", extra)
}
@ -1718,7 +1723,8 @@ func (t *ExpTipSet) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.Cids: array too large (%d)", extra)
}
@ -1743,7 +1749,8 @@ func (t *ExpTipSet) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.Blocks: array too large (%d)", extra)
}

View File

@ -79,10 +79,10 @@ func (t *VoucherInfo) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Proof: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Proof: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -197,7 +197,8 @@ func (t *ChannelInfo) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.Vouchers: array too large (%d)", extra)
}

View File

@ -432,10 +432,10 @@ func (t *Block) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Prefix: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Prefix: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -449,10 +449,10 @@ func (t *Block) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Data: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Data: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}

View File

@ -67,10 +67,10 @@ func (t *SealTicket) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.TicketBytes: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.TicketBytes: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -136,10 +136,10 @@ func (t *SealSeed) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.TicketBytes: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.TicketBytes: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -220,10 +220,10 @@ func (t *Piece) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.CommP: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.CommP: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -388,7 +388,8 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
if extra > cbg.MaxLength {
return fmt.Errorf("t.Pieces: array too large (%d)", extra)
}
@ -414,10 +415,10 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Pad0: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Pad0: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -431,10 +432,10 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.CommD: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.CommD: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -448,10 +449,10 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.CommR: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.CommR: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -465,10 +466,10 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Pad1: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Pad1: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
@ -482,10 +483,10 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
if err != nil {
return err
}
if extra > 8192 {
return fmt.Errorf("t.Proof: array too large (%d)", extra)
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Proof: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}