diff --git a/Cargo.toml b/Cargo.toml index 1fe90f09..244c1a06 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,6 @@ __rustls-tls = ["rustls", "rustls-pki-types"] [dependencies] data-encoding = { version = "2", optional = true } -byteorder = "1.3.2" bytes = "1.9.0" http = { version = "1.0", optional = true } httparse = { version = "1.3.4", optional = true } diff --git a/src/protocol/frame/frame.rs b/src/protocol/frame/frame.rs index 31a4c004..baede5bf 100644 --- a/src/protocol/frame/frame.rs +++ b/src/protocol/frame/frame.rs @@ -1,4 +1,3 @@ -use byteorder::{NetworkEndian, ReadBytesExt}; use log::*; use std::{ default::Default, @@ -161,14 +160,14 @@ impl FrameHeader { let length_byte = second & 0x7F; let length_length = LengthFormat::for_byte(length_byte).extra_bytes(); if length_length > 0 { - match cursor.read_uint::(length_length) { - Err(ref err) if err.kind() == ErrorKind::UnexpectedEof => { - return Ok(None); - } - Err(err) => { - return Err(err.into()); - } - Ok(read) => read, + const SIZE: usize = mem::size_of::(); + assert!(length_length <= SIZE, "length exceeded size of u64"); + let start = SIZE - length_length; + let mut buffer = [0; SIZE]; + match cursor.read_exact(&mut buffer[start..]) { + Err(ref err) if err.kind() == ErrorKind::UnexpectedEof => return Ok(None), + Err(err) => return Err(err.into()), + Ok(()) => u64::from_be_bytes(buffer), } } else { u64::from(length_byte)