X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Flzx_decompress.c;h=86c0839038ac0d396acf65ff88c3e62e7e828e69;hp=67fbea940f0f5ca3b00d5b921445d1048a1a6772;hb=141ce5b36cf27f8b1a78f17d070f6a627105aabd;hpb=3e8aa757aaa63297f0d54007adf46411778fb6a8 diff --git a/src/lzx_decompress.c b/src/lzx_decompress.c index 67fbea94..86c08390 100644 --- a/src/lzx_decompress.c +++ b/src/lzx_decompress.c @@ -54,14 +54,14 @@ # include "config.h" #endif +#include + #include "wimlib/decompressor_ops.h" #include "wimlib/decompress_common.h" #include "wimlib/error.h" #include "wimlib/lzx_common.h" #include "wimlib/util.h" -#include - /* These values are chosen for fast decompression. */ #define LZX_MAINCODE_TABLEBITS 11 #define LZX_LENCODE_TABLEBITS 10 @@ -116,7 +116,7 @@ struct lzx_decompressor { }; /* Read a Huffman-encoded symbol using the precode. */ -static inline u16 +static inline unsigned read_huffsym_using_precode(struct input_bitstream *istream, const u16 precode_decode_table[]) { @@ -125,7 +125,7 @@ read_huffsym_using_precode(struct input_bitstream *istream, } /* Read a Huffman-encoded symbol using the main code. */ -static inline u16 +static inline unsigned read_huffsym_using_maincode(struct input_bitstream *istream, const struct lzx_tables *tables) { @@ -134,7 +134,7 @@ read_huffsym_using_maincode(struct input_bitstream *istream, } /* Read a Huffman-encoded symbol using the length code. */ -static inline u16 +static inline unsigned read_huffsym_using_lencode(struct input_bitstream *istream, const struct lzx_tables *tables) { @@ -143,7 +143,7 @@ read_huffsym_using_lencode(struct input_bitstream *istream, } /* Read a Huffman-encoded symbol using the aligned offset code. */ -static inline u16 +static inline unsigned read_huffsym_using_alignedcode(struct input_bitstream *istream, const struct lzx_tables *tables) { @@ -228,6 +228,8 @@ lzx_read_codeword_lens(struct input_bitstream *istream, u8 *lens, unsigned num_l run_len = 4 + bitstream_read_bits(istream, 1); presym = read_huffsym_using_precode(istream, precode_decode_table); + if (unlikely(presym > 17)) + return -1; len = *len_ptr - presym; if ((s8)len < 0) len += 17;