libhtp: fix newer clippy lints with newer MSRV

pull/14055/head
Philippe Antoine 11 months ago committed by Victor Julien
parent bc33bd49eb
commit f25194480c

@ -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"))
}
}

@ -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)]

@ -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())
}

@ -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())
}

Loading…
Cancel
Save