If version of compression algorithm in file header is 1, 80 distance codes (DCX = 80) are used instead of DCB = 64 in basic algorithm. It extends possible distances up to 1 TB.
It also increases the total Huffman table size from HUFF_TABLE_SIZEB to HUFF_TABLE_SIZEX. Unpacking function utilizes ExtraDist variable to know the proper table size.
To allow not power of 2 dictionary sizes, all &MaxWinMask and &=MaxWinMask are replaced with WrapUp and WrapDown functions. In places where it is not performance critical, we can use %MaxWinSize instead of WrapUp. But we can't use %MaxWinSize instead of WrapDown, because here we need the modulo operation instead of reminder.
We added "if (SrcPtr<MaxWinSize)" check to Unpack::CopyString() and FragmentedWindow::CopyString() to properly process malformed archives, where match distance exceeds the declared dictionary size. Also we must use %MaxWinSize instead of WrapUp in Unpack::AddFilter(). Otherwise FilterStart can be outside of dictionary even after WrapUp call when processing a malformed archive.
UnRAR code prohibits unpacking more than 4 GB dictionaries unless an appropriate -md or -mdx switch is specified. It is done to prevent the unexpected excessive memory allocation. If you integrate UnRAR source into your application, it is recommended to either reject such archives or issue a prompt to user. Otherwise a malicious person could send an archive with 1 TB dictionary to a user to allocate all available memory and make the system unresponsive.
FCI_RAR5_COMPAT and UNPACK_MAX_DICT values have been added in UnRAR source code 7.0.3. If earlier version of UnRAR 7 source code was integrated into application, it is necessary to update it to support them.