diff --git a/rust/htp/src/decompressors.rs b/rust/htp/src/decompressors.rs index e2f908e1ed..4f683a9577 100644 --- a/rust/htp/src/decompressors.rs +++ b/rust/htp/src/decompressors.rs @@ -699,11 +699,9 @@ impl BufWriter for LzmaBufWriter { fn finish(self: Box) -> std::io::Result { self.0.finish().map_err(|e| match e { lzma_rs::error::Error::IoError(e) => e, - lzma_rs::error::Error::HeaderTooShort(e) => { - std::io::Error::new(std::io::ErrorKind::Other, format!("{e}")) - } + lzma_rs::error::Error::HeaderTooShort(e) => std::io::Error::other(format!("{e}")), lzma_rs::error::Error::LzmaError(e) | lzma_rs::error::Error::XzError(e) => { - std::io::Error::new(std::io::ErrorKind::Other, e) + std::io::Error::other(e) } }) } @@ -734,7 +732,7 @@ impl BufWriter for BrotliBufWriter { fn finish(self: Box) -> std::io::Result { self.0 .into_inner() - .map_err(|_e| std::io::Error::new(std::io::ErrorKind::Other, "brotli")) + .map_err(|_e| std::io::Error::other("brotli")) } fn try_finish(&mut self) -> std::io::Result<()> { @@ -794,10 +792,7 @@ impl InnerDecompressor { Ok((Box::new(NullBufWriter(buf)), true)) } } - HtpContentEncoding::None => Err(std::io::Error::new( - std::io::ErrorKind::Other, - "expected a valid encoding", - )), + HtpContentEncoding::None => Err(std::io::Error::other("expected a valid encoding")), } } @@ -867,10 +862,7 @@ impl InnerDecompressor { self.inner.replace(inner); Ok(()) } else { - Err(std::io::Error::new( - std::io::ErrorKind::Other, - "nothing to flush to", - )) + Err(std::io::Error::other("nothing to flush to")) } } @@ -989,10 +981,7 @@ impl Decompress for InnerDecompressor { HtpContentEncoding::Lzma => HtpContentEncoding::Deflate, HtpContentEncoding::Brotli => HtpContentEncoding::Deflate, HtpContentEncoding::None => { - return Err(std::io::Error::new( - std::io::ErrorKind::Other, - "expected a valid encoding", - )) + return Err(std::io::Error::other("expected a valid encoding")) } }; let (writer, passthrough) = Self::writer(self.encoding, &self.options)?; @@ -1003,10 +992,7 @@ impl Decompress for InnerDecompressor { self.restarts += 1; Ok(()) } else { - Err(std::io::Error::new( - std::io::ErrorKind::Other, - "too many restart attempts", - )) + Err(std::io::Error::other("too many restart attempts")) } } diff --git a/rust/htp/src/lib.rs b/rust/htp/src/lib.rs index 0bd93ed559..2060cbb8ff 100644 --- a/rust/htp/src/lib.rs +++ b/rust/htp/src/lib.rs @@ -9,8 +9,6 @@ // Allow unknown lints, our MSRV doesn't know them all, for // example static_mut_refs. #![allow(unknown_lints)] -// Requires MSRV of 1.74 to fix. -#![allow(clippy::io_other_error)] #[repr(C)] #[derive(PartialEq, Eq, Debug)] diff --git a/rust/htp/src/request.rs b/rust/htp/src/request.rs index 0f518e77ac..8ceb9bbad9 100644 --- a/rust/htp/src/request.rs +++ b/rust/htp/src/request.rs @@ -1287,7 +1287,7 @@ impl ConnectionParser { // Invoke all callbacks. self.request_run_hook_body_data(&mut tx_data) - .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "body data hook failed"))?; + .map_err(|_| std::io::Error::other("body data hook failed"))?; let compression_options = self.cfg.compression_options; let req = self.request_mut().unwrap(); @@ -1328,10 +1328,7 @@ impl ConnectionParser { request_entity_len, request_message_len, ) ); - return Err(std::io::Error::new( - std::io::ErrorKind::Other, - "compression_bomb_limit reached", - )); + return Err(std::io::Error::other("compression_bomb_limit reached")); } Ok(tx_data.len()) } diff --git a/rust/htp/src/response.rs b/rust/htp/src/response.rs index 604551b1fa..0d59a6e00a 100644 --- a/rust/htp/src/response.rs +++ b/rust/htp/src/response.rs @@ -1263,7 +1263,7 @@ impl ConnectionParser { // Invoke all callbacks. self.response_run_hook_body_data(&mut tx_data) - .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "body data hook failed"))?; + .map_err(|_| std::io::Error::other("body data hook failed"))?; let resp = self.response_mut().unwrap(); if let Some(decompressor) = &mut resp.response_decompressor { if decompressor.callback_inc() % compression_options.get_time_test_freq() == 0 { @@ -1302,10 +1302,7 @@ impl ConnectionParser { response_entity_len, response_message_len, ) ); - return Err(std::io::Error::new( - std::io::ErrorKind::Other, - "compression_bomb_limit reached", - )); + return Err(std::io::Error::other("compression_bomb_limit reached")); } Ok(tx_data.len()) }