Skip to content

Commit

Permalink
fix client state: disallow empty chain id
Browse files Browse the repository at this point in the history
  • Loading branch information
avahowell committed Jun 5, 2024
1 parent e9830b5 commit 73da5ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/ibc-types-lightclients-tendermint/src/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ impl ClientState {
});
}

if chain_id.as_str() == "" {
return Err(Error::ChainIdEmpty);
}

// `TrustThreshold` is guaranteed to be in the range `[0, 1)`, but a `TrustThreshold::ZERO`
// value is invalid in this context
if trust_level == TrustThreshold::ZERO {
Expand Down
2 changes: 2 additions & 0 deletions crates/ibc-types-lightclients-tendermint/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ pub enum Error {
len: usize,
max_len: usize,
},
/// Chain ID cannot be empty
ChainIdEmpty,
/// invalid header, failed basic validation: `{reason}`, error: `{error}`
InvalidHeader {
reason: String,
Expand Down

0 comments on commit 73da5ee

Please sign in to comment.