-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
node:zlib
fails to decompress brotli data larger than 4096 bytes
#19816
Comments
node:zlib
fails node:zlib
fails to decompress brotli data larger than 4096 bytes
I have determined why this happens. The Rust code FFIs out to this C function. On line 2283, you can see that all non-success results are coerced to the same generic error code Possible solutions are to upstream a change to |
Upstreaming seems like a bad idea, this has been the API for something like 8 years and it's documented, so not a mistake. When I rewrite fn brotli_decompress(buffer: &[u8]) -> Result<ToJsBuffer, AnyError> {
let mut output = Vec::with_capacity(4096);
let mut decompressor = Decompressor::new(buffer, buffer.len());
decompressor.read_to_end(&mut output)?;
Ok(output.into())
} it passes the test in this issue. @littledivy is there a reason you wrote new unsafe FFI code here instead of using the Rust API in the |
This is the PR where this code was introduced by the way: #19223 |
Okay I have looked a little bit more closely into the We should definitely switch this over to the Rust API because the unsafe C API is just a layer of indirection on top of Rust. |
…es (denoland#20301) Fixes denoland#19816 In that issue, I suggest switching over the other brotli functionality to the Rust API provided by the `brotli` crate. Here, I only do that with the `brotli_decompress` function to fix the bug with buffers longer than 4096 bytes.
Steps to reproduce
This works with
"a".repeat(4096)
version
The text was updated successfully, but these errors were encountered: