Skip to content

Commit 1cf3539

Browse files
authored
chore: limit packet data to length of one. (#7484)
1 parent dd675cf commit 1cf3539

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

modules/core/04-channel/v2/types/msgs_test.go

+28
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,13 @@ func (s *TypesTestSuite) TestMsgSendPacketValidateBasic() {
175175
},
176176
{
177177
name: "failure: invalid length for payload",
178+
malleate: func() {
179+
msg.Payloads = []types.Payload{{}, {}}
180+
},
181+
expError: types.ErrInvalidPayload,
182+
},
183+
{
184+
name: "failure: invalid packetdata",
178185
malleate: func() {
179186
msg.Payloads = []types.Payload{}
180187
},
@@ -241,6 +248,13 @@ func (s *TypesTestSuite) TestMsgRecvPacketValidateBasic() {
241248
},
242249
expError: commitmenttypes.ErrInvalidProof,
243250
},
251+
{
252+
name: "failure: invalid length for packet payloads",
253+
malleate: func() {
254+
msg.Packet.Payloads = []types.Payload{{}, {}}
255+
},
256+
expError: types.ErrInvalidPacket,
257+
},
244258
{
245259
name: "failure: invalid signer",
246260
malleate: func() {
@@ -288,6 +302,13 @@ func (s *TypesTestSuite) TestMsgAcknowledge_ValidateBasic() {
288302
},
289303
expError: commitmenttypes.ErrInvalidProof,
290304
},
305+
{
306+
name: "failure: invalid length for packet payloads",
307+
malleate: func() {
308+
msg.Packet.Payloads = []types.Payload{{}, {}}
309+
},
310+
expError: types.ErrInvalidPacket,
311+
},
291312
{
292313
name: "failure: invalid signer",
293314
malleate: func() {
@@ -345,6 +366,13 @@ func (s *TypesTestSuite) TestMsgTimeoutValidateBasic() {
345366
},
346367
expError: ibcerrors.ErrInvalidAddress,
347368
},
369+
{
370+
name: "failure: invalid length for packet payloads",
371+
malleate: func() {
372+
msg.Packet.Payloads = []types.Payload{{}, {}}
373+
},
374+
expError: types.ErrInvalidPacket,
375+
},
348376
{
349377
name: "failure: invalid packet",
350378
malleate: func() {

modules/core/04-channel/v2/types/packet.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func NewPayload(sourcePort, destPort, version, encoding string, value []byte) Pa
3232

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

0 commit comments

Comments
 (0)