From d0f33d672a4da7985ebb5ba8d829f885de49c171 Mon Sep 17 00:00:00 2001 From: Jia Tan Date: Mon, 8 May 2023 22:58:09 +0800 Subject: liblzma: Creates IS_ENC_DICT_SIZE_VALID() macro. This creates an internal liblzma macro to test if the dictionary size is valid for encoding. --- src/liblzma/lz/lz_encoder.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/liblzma/lz/lz_encoder.h') diff --git a/src/liblzma/lz/lz_encoder.h b/src/liblzma/lz/lz_encoder.h index 7950a2f4..2027b39f 100644 --- a/src/liblzma/lz/lz_encoder.h +++ b/src/liblzma/lz/lz_encoder.h @@ -17,6 +17,14 @@ #include "common.h" +// For now, the dictionary size is limited to 1.5 GiB. This may grow +// in the future if needed, but it needs a little more work than just +// changing this check. +#define IS_ENC_DICT_SIZE_VALID(size) \ + ((size) >= LZMA_DICT_SIZE_MIN \ + && (size) <= (UINT32_C(1) << 30) + (UINT32_C(1) << 29)) + + /// A table of these is used by the LZ-based encoder to hold /// the length-distance pairs found by the match finder. typedef struct { -- cgit v1.2.3