Skip to content

Commit

Permalink
fix: ics27 check packet data length explicitly over nil check (#1882) (
Browse files Browse the repository at this point in the history
…#1897)

* using len check in favour of nil check for interchain account packet data

* adding changelog

* updating changelog

(cherry picked from commit 73fdde9)

Co-authored-by: Damian Nolan <[email protected]>
  • Loading branch information
mergify[bot] and damiannolan authored Aug 7, 2022
1 parent 6e0d4c7 commit c60104f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Ref: https://keepachangelog.com/en/1.0.0/

### State Machine Breaking

* (apps/27-interchain-accounts) [\#1882](https://github.com/cosmos/ibc-go/pull/1882) Explicitly check length of interchain account packet data in favour of nil check.

### Improvements

* (core/02-client) [\#1570](https://github.com/cosmos/ibc-go/pull/1570) Emitting an event when handling an upgrade client proposal.
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/27-interchain-accounts/types/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func (iapd InterchainAccountPacketData) ValidateBasic() error {
return sdkerrors.Wrap(ErrInvalidOutgoingData, "packet data type cannot be unspecified")
}

if iapd.Data == nil {
if len(iapd.Data) == 0 {
return sdkerrors.Wrap(ErrInvalidOutgoingData, "packet data cannot be empty")
}

Expand Down
9 changes: 9 additions & 0 deletions modules/apps/27-interchain-accounts/types/packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ func (suite *TypesTestSuite) TestValidateBasic() {
},
{
"empty data",
types.InterchainAccountPacketData{
Type: types.EXECUTE_TX,
Data: []byte{},
Memo: "memo",
},
false,
},
{
"nil data",
types.InterchainAccountPacketData{
Type: types.EXECUTE_TX,
Data: nil,
Expand Down

0 comments on commit c60104f

Please sign in to comment.