diff options
author | Michihiro NAKAJIMA <ggcueroad@gmail.com> | 2011-09-04 05:08:25 -0400 |
---|---|---|
committer | Michihiro NAKAJIMA <ggcueroad@gmail.com> | 2011-09-04 05:08:25 -0400 |
commit | 17f740281995269f3b1185809c0e3b8f812e252c (patch) | |
tree | f5804a5e156bd7244106104b60677f8de794a7b1 /libarchive/archive_read_support_format_cab.c | |
parent | 13b415ac93e99994a752ccc1a53af0f0b3311fc3 (diff) | |
download | libarchive-17f740281995269f3b1185809c0e3b8f812e252c.tar.gz |
LZX fotter-bits can take 17 bits, and so a bit reader should handle
over 16 bits in the bit stream.
SVN-Revision: 3674
Diffstat (limited to 'libarchive/archive_read_support_format_cab.c')
-rw-r--r-- | libarchive/archive_read_support_format_cab.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/libarchive/archive_read_support_format_cab.c b/libarchive/archive_read_support_format_cab.c index a157b3b8..b8346c69 100644 --- a/libarchive/archive_read_support_format_cab.c +++ b/libarchive/archive_read_support_format_cab.c @@ -2206,10 +2206,10 @@ lzx_translation(struct lzx_stream *strm, void *p, size_t size, uint32_t offset) #define lzx_br_has(br, n) ((br)->cache_avail >= n) /* Get compressed data by bit. */ #define lzx_br_bits(br, n) \ - (((uint16_t)((br)->cache_buffer >> \ + (((uint32_t)((br)->cache_buffer >> \ ((br)->cache_avail - (n)))) & cache_masks[n]) #define lzx_br_bits_forced(br, n) \ - (((uint16_t)((br)->cache_buffer << \ + (((uint32_t)((br)->cache_buffer << \ ((n) - (br)->cache_avail))) & cache_masks[n]) /* Read ahead to make sure the cache buffer has enough compressed data we * will use. @@ -2228,12 +2228,16 @@ lzx_translation(struct lzx_stream *strm, void *p, size_t size, uint32_t offset) #define lzx_br_consume(br, n) ((br)->cache_avail -= (n)) #define lzx_br_consume_unalined_bits(br) ((br)->cache_avail &= ~0x0f) -static const uint16_t cache_masks[] = { - 0x0000, 0x0001, 0x0003, 0x0007, - 0x000F, 0x001F, 0x003F, 0x007F, - 0x00FF, 0x01FF, 0x03FF, 0x07FF, - 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, - 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF +static const uint32_t cache_masks[] = { + 0x00000000, 0x00000001, 0x00000003, 0x00000007, + 0x0000000F, 0x0000001F, 0x0000003F, 0x0000007F, + 0x000000FF, 0x000001FF, 0x000003FF, 0x000007FF, + 0x00000FFF, 0x00001FFF, 0x00003FFF, 0x00007FFF, + 0x0000FFFF, 0x0001FFFF, 0x0003FFFF, 0x0007FFFF, + 0x000FFFFF, 0x001FFFFF, 0x003FFFFF, 0x007FFFFF, + 0x00FFFFFF, 0x01FFFFFF, 0x03FFFFFF, 0x07FFFFFF, + 0x0FFFFFFF, 0x1FFFFFFF, 0x3FFFFFFF, 0x7FFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; /* |