Skip to content

Commit

Permalink
Merge branch 'v0.44'
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugeny committed Aug 14, 2024
2 parents 4eaa080 + ba8bde9 commit 45353c3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion russh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license = "Apache-2.0"
name = "russh"
readme = "../README.md"
repository = "https://github.com/warp-tech/russh"
version = "0.44.0"
version = "0.44.1"
rust-version = "1.65"

[features]
Expand Down
9 changes: 8 additions & 1 deletion russh/src/cipher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,13 @@ pub(crate) async fn read<'a, R: AsyncRead + Unpin>(
buffer.buffer.extend(&len);
debug!("reading, seqn = {:?}", seqn);
let len = cipher.decrypt_packet_length(seqn, &len);
buffer.len = BigEndian::read_u32(&len) as usize + cipher.tag_len();
let len = BigEndian::read_u32(&len) as usize;

if len > MAXIMUM_PACKET_LEN {
return Err(Error::PacketSize(len));
}

buffer.len = len + cipher.tag_len();
debug!("reading, clear len = {:?}", buffer.len);
}
}
Expand Down Expand Up @@ -284,5 +290,6 @@ pub(crate) async fn read<'a, R: AsyncRead + Unpin>(
pub(crate) const PACKET_LENGTH_LEN: usize = 4;

const MINIMUM_PACKET_LEN: usize = 16;
const MAXIMUM_PACKET_LEN: usize = 256 * 1024;

const PADDING_LENGTH_LEN: usize = 1;
4 changes: 4 additions & 0 deletions russh/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ pub enum Error {
#[error("Wrong server signature")]
WrongServerSig,

/// Excessive packet size.
#[error("Bad packet size: {0}")]
PacketSize(usize),

/// Message received/sent on unopened channel.
#[error("Channel not open")]
WrongChannel,
Expand Down

0 comments on commit 45353c3

Please sign in to comment.