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)

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

* adding changelog

* updating changelog
  • Loading branch information
damiannolan authored Aug 5, 2022
1 parent 45da8ac commit 73fdde9
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 @@ -64,6 +64,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

* (linting) [\#1418](https://github.com/cosmos/ibc-go/pull/1418) Fix linting errors, resulting compatiblity with go1.18 linting style, golangci-lint 1.46.2 and the revivie linter. This caused breaking changes in core/04-channel, core/ante, and the testing library.
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 73fdde9

Please sign in to comment.