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

Fix corruption that rarely occurs in 32-bit mode with wlog=25 #3361

Merged
merged 1 commit into from
Dec 15, 2022

Commits on Dec 15, 2022

  1. Fix corruption that rarely occurs in 32-bit mode with wlog=25

    Fix an off-by-one error in the compressor that emits corrupt blocks if:
    
    * Zstd is compiled in 32-bit mode
    * The windowLog == 25 exactly
    * An offset of 2^25-3, 2^25-2, 2^25-1, or 2^25 is emitted
    * The bitstream had 7 bits leftover before writing the offset
    
    This bug has been present since before v1.0, but wasn't able to easily
    be triggered, since until somewhat recently zstd wasn't able to find
    matches that were within 128KB of the window size.
    
    Add a test case, and fix 2 bugs in `ZSTD_compressSequences()`:
    * The `ZSTD_isRLE()` check was incorrect. It wouldn't produce
      corruption, but it could waste CPU and not emit RLE even if the block
      was RLE
    * One windowSize was `1 << windowLog`, not `1u << windowLog`
    
    Thanks to @tansy for finding the issue, and giving us a reproducer!
    
    Fixes Issue facebook#3350.
    terrelln committed Dec 15, 2022
    Configuration menu
    Copy the full SHA
    036d5ac View commit details
    Browse the repository at this point in the history