mirror of
https://github.com/intel/isa-l.git
synced 2025-10-28 11:31:51 +01:00
igzip: Fix portability issue when bad window size passed
If a user passes an invalid size for window bits it could have triggered an undefined shift by larger than variable size. Change-Id: Ib2999b094af075596be3333418667ae9b498e2ae Signed-off-by: Greg Tucker <greg.b.tucker@intel.com>
This commit is contained in:
@@ -933,13 +933,16 @@ static inline void reset_match_history(struct isal_zstream *stream)
|
||||
static void inline set_dist_mask(struct isal_zstream *stream)
|
||||
{
|
||||
struct isal_zstate *state = &stream->internal_state;
|
||||
uint32_t hist_size = (1 << (stream->hist_bits));
|
||||
uint32_t hist_size;
|
||||
|
||||
if (stream->hist_bits != 0 && hist_size < IGZIP_HIST_SIZE)
|
||||
state->dist_mask = hist_size - 1;
|
||||
else
|
||||
if (stream->hist_bits > ISAL_DEF_MAX_HIST_BITS || stream->hist_bits == 0)
|
||||
stream->hist_bits = ISAL_DEF_MAX_HIST_BITS;
|
||||
|
||||
hist_size = (1 << (stream->hist_bits));
|
||||
state->dist_mask = hist_size - 1;
|
||||
|
||||
if (IGZIP_HIST_SIZE < ISAL_DEF_HIST_SIZE && state->dist_mask > IGZIP_HIST_SIZE - 1)
|
||||
state->dist_mask = IGZIP_HIST_SIZE - 1;
|
||||
|
||||
}
|
||||
|
||||
static void inline set_hash_mask(struct isal_zstream *stream)
|
||||
|
||||
@@ -84,6 +84,7 @@ extern "C" {
|
||||
#define ISAL_DEF_MAX_HDR_SIZE 328
|
||||
#define ISAL_DEF_MAX_CODE_LEN 15
|
||||
#define ISAL_DEF_HIST_SIZE (32*IGZIP_K)
|
||||
#define ISAL_DEF_MAX_HIST_BITS 15
|
||||
|
||||
#define ISAL_DEF_LIT_SYMBOLS 257
|
||||
#define ISAL_DEF_LEN_SYMBOLS 29
|
||||
|
||||
Reference in New Issue
Block a user