-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BrotliDecompress
panics if output writer stops accepting data
#213
Comments
Two targets to start with: 1) decompression into a growable writer, 2) decompression into a fixed-size buffer, The latter finds dropbox/rust-brotli#213 quite quickly.
Two targets to start with: 1) decompression into a growable writer, 2) decompression into a fixed-size buffer, The latter finds dropbox/rust-brotli#213 quite quickly.
Two targets to start with: 1) decompression into a growable writer, 2) decompression into a fixed-size buffer, The latter finds dropbox/rust-brotli#213 quite quickly.
Is there an analogous bug in the compressor, or did fixing the decompressor also resolve this issue? |
Apologies, I put this issue in the wrong repo. Thanks for taking the decompressor fix and making a release. But for the sake of completeness, here's a test with a similar case on the compressor: diff --git a/src/enc/test.rs b/src/enc/test.rs
index fff4856..2c56f89 100644
--- a/src/enc/test.rs
+++ b/src/enc/test.rs
@@ -549,6 +549,27 @@ fn test_roundtrip_empty() {
assert_eq!(output_offset, 0);
assert_eq!(compressed_offset, compressed.len());
}
+
+#[cfg(feature="std")]
+#[test]
+fn test_compress_into_short_buffer() {
+ use std::io::{Cursor, Write};
+
+ // this plaintext should compress to 11 bytes
+ let plaintext = [0u8; 2048];
+
+ // but we only provide space for 10
+ let mut output_buffer = [0u8; 10];
+ let mut output_cursor = Cursor::new(&mut output_buffer[..]);
+
+ let mut w = crate::CompressorWriter::new(&mut output_cursor,
+ 4096, 4, 22);
+ w.write(&plaintext).unwrap_err();
+ w.into_inner();
+
+ println!("{output_buffer:?}");
+}
+
/*
This test unfortunately does not terminate, as it is making no progress in Lines 131 to 142 in 37d403b
And fixing that seems tricky without a breaking change. Ideally a parameter would be added to this function for the In our use case we compress into a Cursor over a Vec, so won't be affected by this. However happy to put together a PR that:
|
I would really appreciate that PR... this might warrant a breaking change in the future, but maybe we could do a non-breaking release first with your PR and then add that WriteZero capability into the next major version on its heels? |
I think the recent commit has improved the situation--but you're right it's a breaking change--moved version to 7.0.0 |
Reproducer:
This panics for me with:
I think there's a confusion there about what
io::Write::write
is allowed to return --Ok(0)
is valid, and in this case should be be promoted to an error.The text was updated successfully, but these errors were encountered: