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

Bzip2-sys does not support the value 0 for blockSize100k #84

Open
Plecra opened this issue Nov 14, 2022 · 0 comments
Open

Bzip2-sys does not support the value 0 for blockSize100k #84

Plecra opened this issue Nov 14, 2022 · 0 comments

Comments

@Plecra
Copy link

Plecra commented Nov 14, 2022

We are directly passing Compression::level to BZ2_bzCompressInit

/~https://github.com/alexcrichton/bzip2-rs/blob/016e18155ef7c05983ea244cae1344c5b68defd8/src/mem.rs#L123-L126

However, this API only supports values from 1..=9 as documented here in the sources

Parameter blockSize100k specifies the block size to be used for compression. It should be a value between 1 and 9 inclusive, and the actual block size used is 100000 x this figure. 9 gives the best compression but takes most memory.

This bug seems to have been introduced in #37, where we tried to support an API aligned with flate2::Compression. However, our version of Compression::none will always panic on the above assertion with BZ_PARAM_ERROR

/~https://github.com/alexcrichton/bzip2-rs/blob/016e18155ef7c05983ea244cae1344c5b68defd8/src/lib.rs#L100-L102

References

We had a panic in usage of zip over here :) zip-rs/zip-old#326

Suggestions

As the library doesnt appear to support disabling compression, I would prefer none to be deprecated, and a bounds check to be added to Compression::new. Hopefully there's a clean way to provide the equivalent of flate2's none and we can specifically branch on 0?

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

1 participant