Skip to content

Commit

Permalink
fix: ics27 check packet data length explicitly over nil check (cosmos…
Browse files Browse the repository at this point in the history
…#1882) (cosmos#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 <damiannolan@gmail.com>
  • Loading branch information
2 people authored and dudong2 committed Jan 19, 2023
1 parent fb419bc commit 04d40c1
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 @@ -2,6 +2,8 @@

## [Unreleased](https://github.com/line/ibc-go/tree/HEAD)

* (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
* [\#1](https://github.com/line/ibc-go/pull/1) apply all changes of `x/ibc` in lbm-sdk until [lbm-sdk@0fbc2fcae6dba90fa80b815cf3219d6fcf46fc64](https://github.com/line/lbm-sdk/tree/0fbc2fcae6dba90fa80b815cf3219d6fcf46fc64)

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 04d40c1

Please sign in to comment.