From cb92f6f9106f87d53080e286c9cab9595dbb40d9 Mon Sep 17 00:00:00 2001 From: Charly Date: Fri, 18 Nov 2022 14:13:16 +0100 Subject: [PATCH] fix: added check for empty path in 06-solomachine (#2741) --- modules/light-clients/06-solomachine/client_state.go | 4 ++++ modules/light-clients/06-solomachine/client_state_test.go | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/modules/light-clients/06-solomachine/client_state.go b/modules/light-clients/06-solomachine/client_state.go index 36cb1135540..0d515356eee 100644 --- a/modules/light-clients/06-solomachine/client_state.go +++ b/modules/light-clients/06-solomachine/client_state.go @@ -125,6 +125,10 @@ func (cs *ClientState) VerifyMembership( return sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "expected %T, got %T", commitmenttypes.MerklePath{}, path) } + if merklePath.Empty() { + return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "path is empty") + } + signBytes := &SignBytes{ Sequence: sequence, Timestamp: timestamp, diff --git a/modules/light-clients/06-solomachine/client_state_test.go b/modules/light-clients/06-solomachine/client_state_test.go index 3fabbb21783..11507a5eda9 100644 --- a/modules/light-clients/06-solomachine/client_state_test.go +++ b/modules/light-clients/06-solomachine/client_state_test.go @@ -517,6 +517,13 @@ func (suite *SoloMachineTestSuite) TestVerifyMembership() { }, false, }, + { + "empty path", + func() { + path = commitmenttypes.MerklePath{} + }, + false, + }, } for _, tc := range testCases {