Skip to content
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

Brotli body decompression can be corrupted #564

Closed
jcamiel opened this issue May 9, 2022 · 0 comments · Fixed by #570
Closed

Brotli body decompression can be corrupted #564

jcamiel opened this issue May 9, 2022 · 0 comments · Fixed by #570
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jcamiel
Copy link
Collaborator

jcamiel commented May 9, 2022

Given a HTTP binary response compressed with brotli, that is greater than 4096 bytes, the automatically decompressed body will be corrupted when using --compressed option.

For instance, with the attached jpg image compressed with brotli, if we try to decompress it automatically:

$ echo 'GET http://localhost/cat.jpg.br' | hurl --decompressed > /tmp/cat.jpg

We get a corrupted jpg file back.

There is a wrong assumption in the code that the HTTP body response is less than 4096 bytes:

let mut reader = brotli::Decompressor::new(data, 4096);
let mut buf = [0u8; 4096];
let n = match reader.read(&mut buf[..]) {
Err(_) => {

cat.jpg.br.zip

@jcamiel jcamiel added the bug Something isn't working label May 9, 2022
@jcamiel jcamiel self-assigned this May 10, 2022
@jcamiel jcamiel added this to the 1.7.0 milestone May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant