Skip to content

Commit

Permalink
fix: channel close check not enough (#22)
Browse files Browse the repository at this point in the history
Co-authored-by: liyukun <[email protected]>

These checks are also covered in #20 as:

```
    if old.state != State::Open {
        return Err(VerifyError::WrongChannelState);
    }
    if !old_args.open {
        return Err(VerifyError::WrongChannelArgs);
    }

    old.state = State::Closed;
    old_args.open = false;
    if old != new {
        return Err(VerifyError::WrongChannel);
    }
    if old_args != new_args {
        return Err(VerifyError::WrongChannelArgs);
    }
```
  • Loading branch information
ashuralyk authored Nov 21, 2023
1 parent 0299a91 commit 622cecd
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions axon/src/handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,12 @@ pub fn handle_msg_channel_close_init<C: Client>(
if old.state != State::Open || new.state != State::Closed {
return Err(VerifyError::WrongChannelState);
}
if !old_args.open || new_args.open {
if !old_args.open
|| new_args.open
|| old_args.client_id != new_args.client_id
|| old_args.channel_id != new_args.channel_id
|| old_args.port_id != new_args.port_id
{
return Err(VerifyError::WrongChannelArgs);
}
Ok(())
Expand All @@ -454,7 +459,12 @@ pub fn handle_msg_channel_close_confirm<C: Client>(
if old.state != State::Open || new.state != State::Closed {
return Err(VerifyError::WrongChannelState);
}
if !old_args.open || new_args.open {
if !old_args.open
|| new_args.open
|| old_args.client_id != new_args.client_id
|| old_args.channel_id != new_args.channel_id
|| old_args.port_id != new_args.port_id
{
return Err(VerifyError::WrongChannelArgs);
}

Expand Down

0 comments on commit 622cecd

Please sign in to comment.