rikyoz / bit7z

A C++ static library offering a clean and simple interface to the 7-zip shared libraries.
https://rikyoz.github.io/bit7z
Mozilla Public License 2.0
644 stars 118 forks source link

[Bug]: maximum dictionary size limit needs to be increased #256

Open chrisgch opened 1 week ago

chrisgch commented 1 week ago

bit7z version

4.0.x, 3.2.x, 3.1.x, 3.0.x, 2.1, 2.0

Compilation options

No response

7-zip version

v23.01, v22.01, v22.00, v21.07, v21.06

7-zip shared library used

7z.dll / 7z.so

Compilers

MSVC

Compiler versions

No response

Architecture

x86_64, x86

Operating system

Windows

Operating system versions

No response

Bug description

In 7-zip 21.03 beta (2021-07-20), the maximum dictionary size for LZMA/LZMA2 compressing was increased to 4 GB (3840 MiB). See: https://sevenzip.sourceforge.io/history.txt Therefore in file bitabstractarchivecreator.cpp the line constexpr auto kMaxLzmaDictionarySize = 1536 ( 1LL << 20 ); // less than 1536 MiB should be changed to constexpr auto kMaxLzmaDictionarySize = 3840 ( 1LL << 20 ); // less than 3840 MiB

Steps to reproduce

Call: BitFileCompressor compressor{ lib, BitFormat::SevenZip }; compressor.setDictionarySize(3840*( 1LL << 20 ); results in error "Cannot set the dictionary size: Invalid dictionary size for the chosen compression method."

Expected behavior

The larger dictionary size should be passed to the 7zip library.

Relevant compilation output

No response

Code of Conduct

rikyoz commented 1 week ago

Hi! Nice catch, I completely missed that change in the changelog. I'll update the code accordingly and release the fix in the next v4.0.9. Thank you for pointing it out!