This commit is contained in:
nora 2024-08-15 22:16:10 +02:00
parent 7cc5a75fe2
commit b3081cfeb9
5 changed files with 9 additions and 9 deletions

View file

@ -490,7 +490,7 @@ impl ServerChannelsState {
/// Send a single data packet.
/// The caller needs to ensure the windowing and packet size requirements are upheld.
fn send_data_packet(&mut self, channel_number: ChannelNumber, data: &[u8]) {
assert!(data.len() > 0, "Trying to send empty data packet");
assert!(!data.is_empty(), "Trying to send empty data packet");
trace!(%channel_number, amount = %data.len(), "Sending channel data");
let channel = self.channel(channel_number).unwrap();

View file

@ -89,13 +89,13 @@ impl ClientConnection {
self.packet_transport.recv_bytes(bytes)?;
while let Some(packet) = self.packet_transport.recv_next_packet() {
let packet_type = packet.payload.get(0).unwrap_or(&0xFF);
let packet_type = packet.payload.first().unwrap_or(&0xFF);
let packet_type_string = numbers::packet_type_to_string(*packet_type);
trace!(%packet_type, %packet_type_string, packet_len = %packet.payload.len(), "Received packet");
// Handle some packets ignoring the state.
match packet.payload.get(0).copied() {
match packet.payload.first().copied() {
Some(numbers::SSH_MSG_DISCONNECT) => {
// <https://datatracker.ietf.org/doc/html/rfc4253#section-11.1>
let mut disconnect = Parser::new(&packet.payload[1..]);

View file

@ -228,7 +228,7 @@ pub struct AlgorithmNegotiation<T> {
}
impl<T: AlgorithmName> AlgorithmNegotiation<T> {
pub fn find<'a>(mut self, peer_supports: &str) -> Result<T> {
pub fn find(mut self, peer_supports: &str) -> Result<T> {
for client_alg in peer_supports.split(',') {
if let Some(alg) = self
.supported
@ -455,7 +455,7 @@ fn derive_key(
for i in 0..(padded_key_size / sha2len) {
let mut hash = <sha2::Sha256 as sha2::Digest>::new();
encode_mpint_for_hash(&k, |data| hash.update(data));
encode_mpint_for_hash(k, |data| hash.update(data));
hash.update(h);
if i == 0 {

View file

@ -84,7 +84,7 @@ pub fn packet_type_to_string(packet_type: u8) -> &'static str {
98 => "SSH_MSG_CHANNEL_REQUEST",
99 => "SSH_MSG_CHANNEL_SUCCESS",
100 => "SSH_MSG_CHANNEL_FAILURE",
_ => return "<unknown>",
_ => "<unknown>",
}
}

View file

@ -78,13 +78,13 @@ impl ServerConnection {
self.packet_transport.recv_bytes(bytes)?;
while let Some(packet) = self.packet_transport.recv_next_packet() {
let packet_type = packet.payload.get(0).unwrap_or(&0xFF);
let packet_type = packet.payload.first().unwrap_or(&0xFF);
let packet_type_string = numbers::packet_type_to_string(*packet_type);
trace!(%packet_type, %packet_type_string, packet_len = %packet.payload.len(), "Received packet");
// Handle some packets ignoring the state.
match packet.payload.get(0).copied() {
match packet.payload.first().copied() {
Some(numbers::SSH_MSG_DISCONNECT) => {
// <https://datatracker.ietf.org/doc/html/rfc4253#section-11.1>
let mut disconnect = Parser::new(&packet.payload[1..]);
@ -217,7 +217,7 @@ impl ServerConnection {
let pub_hostkey = server_host_key_algorithm.public_key();
let hash = crypto::key_exchange_hash(
&client_identification,
client_identification,
SERVER_IDENTIFICATION,
client_kexinit,
server_kexinit,