]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fix issue 241:CAB decompression not 64bit compatible.
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Tue, 14 Feb 2012 22:15:50 +0000 (07:15 +0900)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Wed, 15 Feb 2012 17:47:05 +0000 (02:47 +0900)
libarchive/archive_read_support_format_cab.c

index d663e2e3c24f8359e2a7cbab2a4f80609790c8ff..b634ed394f35e8ed5b289f19790cd8bfa488fcea 100644 (file)
@@ -2182,11 +2182,11 @@ lzx_translation(struct lzx_stream *strm, void *p, size_t size, uint32_t offset)
        end = b + size - 10;
        while (b < end && (b = memchr(b, 0xE8, end - b)) != NULL) {
                size_t i = b - (unsigned char *)p;
-               long cp, displacement, value;
+               int32_t cp, displacement, value;
 
                cp = offset + i;
                value = archive_le32dec(&b[1]);
-               if (value >= -cp && value < (long)ds->translation_size) {
+               if (value >= -cp && value < (int32_t)ds->translation_size) {
                        if (value >= 0)
                                displacement = value - cp;
                        else
@@ -2477,7 +2477,10 @@ lzx_read_blocks(struct lzx_stream *strm, int last)
                         */
                        /* Skip padding to align following field on
                         * 16-bit boundary. */
-                       lzx_br_consume_unalined_bits(br);
+                       if (br->cache_avail == 32 || br->cache_avail == 16)
+                               lzx_br_consume(br, 16);
+                       else
+                               lzx_br_consume_unalined_bits(br);
                        /* Preparation to read repeated offsets R0,R1 and R2. */
                        ds->rbytes_avail = 0;
                        ds->state = ST_RD_R0;