PSeitz / lz4_flex

Fastest pure Rust implementation of LZ4 compression/decompression.
MIT License
441 stars 28 forks source link

It's not an error to pass a buffer larger than the decompressed data. #37

Closed TannerRogalsky closed 1 year ago

TannerRogalsky commented 2 years ago

As per the reference implementation of LZ4_decompress_safe:

the size of destination buffer (which must be already allocated), presumed an upper bound of decompressed size

I think this mistake originates from a misleading comment on lzzzz which seems to indicate that the buffer must be exactly the size of the decompressed data. However neither those bindings nor the underlying library make that assertion.

This PR is a breaking change since I removed the now unused UncompressedSizeDiffers variant from the DecompressError enum.

codecov-commenter commented 2 years ago

Codecov Report

Merging #37 (93fdf9c) into main (d3e3dab) will increase coverage by 0.90%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #37      +/-   ##
==========================================
+ Coverage   91.07%   91.98%   +0.90%     
==========================================
  Files          11       11              
  Lines        2197     2171      -26     
==========================================
- Hits         2001     1997       -4     
+ Misses        196      174      -22     
Impacted Files Coverage Δ
src/block/mod.rs 25.00% <ø> (+4.41%) :arrow_up:
src/block/decompress.rs 94.44% <100.00%> (+2.01%) :arrow_up:
src/block/decompress_safe.rs 97.11% <100.00%> (+3.04%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update d3e3dab...93fdf9c. Read the comment docs.

PSeitz commented 1 year ago

Thanks, I just realized that in that step only sizes that are larger are checked

It's implemented in this PR: https://github.com/PSeitz/lz4_flex/pull/78