summaryrefslogtreecommitdiffstats
path: root/contrib/libarchive/libarchive/archive_read_support_format_cab.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libarchive/libarchive/archive_read_support_format_cab.c')
-rw-r--r--contrib/libarchive/libarchive/archive_read_support_format_cab.c55
1 files changed, 29 insertions, 26 deletions
diff --git a/contrib/libarchive/libarchive/archive_read_support_format_cab.c b/contrib/libarchive/libarchive/archive_read_support_format_cab.c
index aa0152a..3c9f94c 100644
--- a/contrib/libarchive/libarchive/archive_read_support_format_cab.c
+++ b/contrib/libarchive/libarchive/archive_read_support_format_cab.c
@@ -382,6 +382,7 @@ archive_read_support_format_cab(struct archive *_a)
archive_read_format_cab_read_header,
archive_read_format_cab_read_data,
archive_read_format_cab_read_data_skip,
+ NULL,
archive_read_format_cab_cleanup);
if (r != ARCHIVE_OK)
@@ -539,7 +540,7 @@ truncated_error(struct archive_read *a)
return (ARCHIVE_FATAL);
}
-static int
+static ssize_t
cab_strnlen(const unsigned char *p, size_t maxlen)
{
size_t i;
@@ -550,7 +551,7 @@ cab_strnlen(const unsigned char *p, size_t maxlen)
}
if (i > maxlen)
return (-1);/* invalid */
- return (i);
+ return ((ssize_t)i);
}
/* Read bytes as much as remaining. */
@@ -626,8 +627,9 @@ cab_read_header(struct archive_read *a)
struct cab *cab;
struct cfheader *hd;
size_t bytes, used;
+ ssize_t len;
int64_t skip;
- int err, i, len;
+ int err, i;
int cur_folder, prev_folder;
uint32_t offset32;
@@ -1066,13 +1068,13 @@ static uint32_t
cab_checksum_cfdata_4(const void *p, size_t bytes, uint32_t seed)
{
const unsigned char *b;
- int u32num;
+ unsigned u32num;
uint32_t sum;
- u32num = bytes / 4;
+ u32num = (unsigned)bytes / 4;
sum = seed;
b = p;
- while (--u32num >= 0) {
+ for (;u32num > 0; --u32num) {
sum ^= archive_le32dec(b);
b += 4;
}
@@ -1485,7 +1487,7 @@ cab_read_ahead_cfdata_deflate(struct archive_read *a, ssize_t *avail)
* cast to remove 'const'.
*/
cab->stream.next_in = (Bytef *)(uintptr_t)d;
- cab->stream.avail_in = bytes_avail;
+ cab->stream.avail_in = (uInt)bytes_avail;
cab->stream.total_in = 0;
/* Cut out a tow-byte MSZIP signature(0x43, 0x4b). */
@@ -1506,7 +1508,7 @@ cab_read_ahead_cfdata_deflate(struct archive_read *a, ssize_t *avail)
*avail = ARCHIVE_FATAL;
return (NULL);
}
- mszip -= bytes_avail;
+ mszip -= (int)bytes_avail;
continue;
}
if (mszip == 1 && cab->stream.next_in[0] != 0x4b)
@@ -1935,7 +1937,7 @@ cab_read_data(struct archive_read *a, const void **buff,
ARCHIVE_ERRNO_FILE_FORMAT, "Invalid CFDATA");
return (ARCHIVE_FATAL);
} else
- return (bytes_avail);
+ return ((int)bytes_avail);
}
if (bytes_avail > cab->entry_bytes_remaining)
bytes_avail = (ssize_t)cab->entry_bytes_remaining;
@@ -2001,7 +2003,8 @@ archive_read_format_cab_read_data_skip(struct archive_read *a)
/* If the compression type is none(uncompressed), we've already
* consumed data as much as the current entry size. */
- if (cab->entry_cffolder->comptype == COMPTYPE_NONE)
+ if (cab->entry_cffolder->comptype == COMPTYPE_NONE &&
+ cab->entry_cfdata != NULL)
cab->entry_cfdata->unconsumed = 0;
/* This entry is finished and done. */
@@ -2198,7 +2201,7 @@ lzx_translation(struct lzx_stream *strm, void *p, size_t size, uint32_t offset)
size_t i = b - (unsigned char *)p;
int32_t cp, displacement, value;
- cp = offset + i;
+ cp = (int32_t)(offset + (uint32_t)i);
value = archive_le32dec(&b[1]);
if (value >= -cp && value < (int32_t)ds->translation_size) {
if (value >= 0)
@@ -2584,7 +2587,7 @@ lzx_read_blocks(struct lzx_stream *strm, int last)
goto failed;
return (ARCHIVE_OK);
}
- l = ds->block_bytes_avail;
+ l = (int)ds->block_bytes_avail;
if (l > ds->w_size - ds->w_pos)
l = ds->w_size - ds->w_pos;
if (l > strm->avail_out)
@@ -2746,8 +2749,8 @@ lzx_decode_blocks(struct lzx_stream *strm, int last)
struct lzx_br bre = ds->br;
struct huffman *at = &(ds->at), *lt = &(ds->lt), *mt = &(ds->mt);
const struct lzx_pos_tbl *pos_tbl = ds->pos_tbl;
- unsigned char *outp = strm->next_out;
- unsigned char *endp = outp + strm->avail_out;
+ unsigned char *noutp = strm->next_out;
+ unsigned char *endp = noutp + strm->avail_out;
unsigned char *w_buff = ds->w_buff;
unsigned char *at_bitlen = at->bitlen;
unsigned char *lt_bitlen = lt->bitlen;
@@ -2781,10 +2784,10 @@ lzx_decode_blocks(struct lzx_stream *strm, int last)
ds->position_slot = position_slot;
ds->r0 = r0; ds->r1 = r1; ds->r2 = r2;
ds->w_pos = w_pos;
- strm->avail_out = endp - outp;
+ strm->avail_out = endp - noutp;
return (ARCHIVE_EOF);
}
- if (outp >= endp)
+ if (noutp >= endp)
/* Output buffer is empty. */
goto next_data;
@@ -2818,7 +2821,7 @@ lzx_decode_blocks(struct lzx_stream *strm, int last)
w_buff[w_pos] = c;
w_pos = (w_pos + 1) & w_mask;
/* Store the decoded code to output buffer. */
- *outp++ = c;
+ *noutp++ = c;
block_bytes_avail--;
}
/*
@@ -2963,22 +2966,22 @@ lzx_decode_blocks(struct lzx_stream *strm, int last)
if (l > w_size - w_pos)
l = w_size - w_pos;
}
- if (outp + l >= endp)
- l = endp - outp;
+ if (noutp + l >= endp)
+ l = (int)(endp - noutp);
s = w_buff + copy_pos;
if (l >= 8 && ((copy_pos + l < w_pos)
|| (w_pos + l < copy_pos))) {
memcpy(w_buff + w_pos, s, l);
- memcpy(outp, s, l);
+ memcpy(noutp, s, l);
} else {
unsigned char *d;
int li;
d = w_buff + w_pos;
for (li = 0; li < l; li++)
- outp[li] = d[li] = s[li];
+ noutp[li] = d[li] = s[li];
}
- outp += l;
+ noutp += l;
copy_pos = (copy_pos + l) & w_mask;
w_pos = (w_pos + l) & w_mask;
block_bytes_avail -= l;
@@ -2986,7 +2989,7 @@ lzx_decode_blocks(struct lzx_stream *strm, int last)
/* A copy of current pattern ended. */
break;
copy_len -= l;
- if (outp >= endp) {
+ if (noutp >= endp) {
/* Output buffer is empty. */
state = ST_COPY;
goto next_data;
@@ -3009,7 +3012,7 @@ next_data:
ds->r0 = r0; ds->r1 = r1; ds->r2 = r2;
ds->state = state;
ds->w_pos = w_pos;
- strm->avail_out = endp - outp;
+ strm->avail_out = endp - noutp;
return (ARCHIVE_OK);
}
@@ -3126,7 +3129,7 @@ lzx_huffman_init(struct huffman *hf, size_t len_size, int tbl_bits)
hf->bitlen = calloc(len_size, sizeof(hf->bitlen[0]));
if (hf->bitlen == NULL)
return (ARCHIVE_FATAL);
- hf->len_size = len_size;
+ hf->len_size = (int)len_size;
} else
memset(hf->bitlen, 0, len_size * sizeof(hf->bitlen[0]));
if (hf->tbl == NULL) {
@@ -3134,7 +3137,7 @@ lzx_huffman_init(struct huffman *hf, size_t len_size, int tbl_bits)
bits = tbl_bits;
else
bits = HTBL_BITS;
- hf->tbl = malloc((1 << bits) * sizeof(hf->tbl[0]));
+ hf->tbl = malloc(((size_t)1 << bits) * sizeof(hf->tbl[0]));
if (hf->tbl == NULL)
return (ARCHIVE_FATAL);
hf->tbl_bits = tbl_bits;
OpenPOWER on IntegriCloud