Skip to content

Commit

Permalink
chore: limit packet data to length of one.
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitrisJim committed Oct 21, 2024
1 parent 6078dda commit 1b0f052
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions modules/core/04-channel/v2/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ func (s *TypesTestSuite) TestMsgSendPacketValidateBasic() {
},
{
name: "failure: invalid length for payload",
malleate: func() {
msg.Payloads = []types.Payload{{}, {}}
},
expError: types.ErrInvalidPayload,
},
{
name: "failure: invalid packetdata",
malleate: func() {
msg.Payloads = []types.Payload{}
},
Expand Down Expand Up @@ -241,6 +248,13 @@ func (s *TypesTestSuite) TestMsgRecvPacketValidateBasic() {
},
expError: commitmenttypes.ErrInvalidProof,
},
{
name: "failure: invalid length for packet payloads",
malleate: func() {
msg.Packet.Payloads = []types.Payload{{}, {}}
},
expError: types.ErrInvalidPacket,
},
{
name: "failure: invalid signer",
malleate: func() {
Expand Down Expand Up @@ -288,6 +302,13 @@ func (s *TypesTestSuite) TestMsgAcknowledge_ValidateBasic() {
},
expError: commitmenttypes.ErrInvalidProof,
},
{
name: "failure: invalid length for packet payloads",
malleate: func() {
msg.Packet.Payloads = []types.Payload{{}, {}}
},
expError: types.ErrInvalidPacket,
},
{
name: "failure: invalid signer",
malleate: func() {
Expand Down Expand Up @@ -345,6 +366,13 @@ func (s *TypesTestSuite) TestMsgTimeoutValidateBasic() {
},
expError: ibcerrors.ErrInvalidAddress,
},
{
name: "failure: invalid length for packet payloads",
malleate: func() {
msg.Packet.Payloads = []types.Payload{{}, {}}
},
expError: types.ErrInvalidPacket,
},
{
name: "failure: invalid packet",
malleate: func() {
Expand Down
2 changes: 1 addition & 1 deletion modules/core/04-channel/v2/types/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewPayload(sourcePort, destPort, version, encoding string, value []byte) Pa

// ValidateBasic validates that a Packet satisfies the basic requirements.
func (p Packet) ValidateBasic() error {
if len(p.Payloads) == 0 {
if len(p.Payloads) != 1 {
return errorsmod.Wrap(ErrInvalidPacket, "payloads must not be empty")
}

Expand Down

0 comments on commit 1b0f052

Please sign in to comment.