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

corrupt stream with extra bytes is not rejected #83

Closed
jsha opened this issue Oct 30, 2022 · 2 comments
Closed

corrupt stream with extra bytes is not rejected #83

jsha opened this issue Oct 30, 2022 · 2 comments

Comments

@jsha
Copy link

jsha commented Oct 30, 2022

Steps to reproduce:

Read a Brotli stream with extra junk at the end.

Expected result:

Receive an Err from brotli_decompressor::Decompressor::read.

Actual result:

No error.

For comparison, the brotli command line tool rejects streams with extra junk at the end:

$ (brotli -c <<<"hello"; echo goodbye) > corrupt.br
$ brotli -d < corrupt.br
hello
corrupt input [con]
$ echo $?
1

Test code to reproduce:

    #[test]
    fn test_no_leftovers() {
        // Output from this command:
        // (brotli -c <<<"hello"; echo goodbye) | xxd -p | sed 's/../\\x&/g'
        let compressed_with_extra = b"\x8f\x02\x80\x68\x65\x6c\x6c\x6f\x0a\x03\x67\x6f\x6f\x64\x62\x79\x65\x0a";
        let mut reader = brotli_decompressor::Decompressor::new(Cursor::new(compressed_with_extra), 8000);
        assert!(std::io::read_to_string(&mut reader).is_err());
    }
@danielrh
Copy link
Collaborator

Fixed by 0045b6e18a91b12937ffc45a7a4f934ffeab7d2e in rust-brotli-decompressor

@catenacyber
Copy link

Looks like the same root cause as dropbox/rust-brotli-decompressor#24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants