Zlib succes while miniz_oxide fails
catenacyber opened this issue · 5 comments
Using code
use flate2::read::DeflateDecoder;
use std::io::prelude::*;
fn main() {
let mut v1 = Vec::new();
v1.extend_from_slice(&[0xf2, 0x48, 0xcd, 0xc9, 0xc9, 0x07, 0x00]);
v1.extend_from_slice(&[0, 0, 0xFF, 0xFF]);
let mut d = DeflateDecoder::new(&v1[..]);
let mut s = String::new();
d.read_to_string(&mut s).unwrap();
println!("{}", s);
}
And Cargo.toml
[dependencies]
flate2 = { version = "1.0.28", default-features = true }
panicks
thread 'main' panicked at src/main.rs:10:30:
called `Result::unwrap()` on an `Err` value: Custom { kind: InvalidInput, error: "corrupt deflate stream" }
While Cargo.toml
[dependencies]
flate2 = { version = "1.0.28", features = ["zlib"], default-features = false }
succeeds in printing Hello
@alexcrichton this example comes from https://datatracker.ietf.org/doc/html/rfc7692#section-7.2.3.1
One fix may be in inflate_loop
Instead of
if (status as i32) < 0 {
return Err(MZError::Data);
}
add a check before like
if (status == TINFLStatus::FailedCannotMakeProgress) && orig_in_len == 0 {
return Err(MZError::Buf);
}
Thanks for bringing this up!
To me it seems that rather than making this specific case work by adjusting inflate_loop
, miniz_oxide
should be changed to report results similarly to zlib
.
If you agree, this issue could be closed in favour of a similar one over at miniz_oxide
. Maybe I am missing something though.
miniz_oxide should be changed to report results similarly to zlib.
I agree.
Maybe I am missing something though.
Maybe I am missing something as well (like I should not use a Vec but another structure)
If you agree, this issue could be closed in favour of a similar one over at miniz_oxide.
Did you open one there already ? Or should I (next year) ?
Did you open one there already ? Or should I (next year) ?
I'd be grateful if you would open the issue and manage it whenever you get the chance.
Thanks a lot!
Closing in favor of Frommi/miniz_oxide#143