]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
libhtp: fix newer clippy lints with newer MSRV
authorPhilippe Antoine <pantoine@oisf.net>
Thu, 16 Oct 2025 07:13:52 +0000 (09:13 +0200)
committerVictor Julien <victor@inliniac.net>
Thu, 16 Oct 2025 19:33:32 +0000 (21:33 +0200)
rust/htp/src/decompressors.rs
rust/htp/src/lib.rs
rust/htp/src/request.rs
rust/htp/src/response.rs

index e2f908e1ed427d382cad688fa4b6c503cc553fe7..4f683a9577405a45ba4b02283565fb56bcd73484 100644 (file)
@@ -699,11 +699,9 @@ impl BufWriter for LzmaBufWriter {
     fn finish(self: Box<Self>) -> std::io::Result<BlockingCursor> {
         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<Self>) -> std::io::Result<BlockingCursor> {
         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"))
         }
     }
 
index 0bd93ed5594157adf76259d4bb493a59af4d01f0..2060cbb8ff247ad7114216867f9701528ddec6ed 100644 (file)
@@ -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)]
index 0f518e77ac23dfbed6d9d98aa66a7a5691be18c8..8ceb9bbad9e3b15c6e78665a0d686ef26ffdb409 100644 (file)
@@ -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())
     }
index 604551b1fa7e3e0aa1f278976ed082c938232c78..0d59a6e00a3146e2ca7dcc4ddd357588974d26c4 100644 (file)
@@ -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())
     }