VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common/libzip/zip_algorithm_bzip2.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common/libzip/zip_algorithm_bzip2.c')
-rw-r--r--src/Common/libzip/zip_algorithm_bzip2.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/Common/libzip/zip_algorithm_bzip2.c b/src/Common/libzip/zip_algorithm_bzip2.c
index c79cb8aa..f25be143 100644
--- a/src/Common/libzip/zip_algorithm_bzip2.c
+++ b/src/Common/libzip/zip_algorithm_bzip2.c
@@ -58,7 +58,7 @@ maximum_compressed_size(zip_uint64_t uncompressed_size) {
static void *
-allocate(bool compress, int compression_flags, zip_error_t *error) {
+allocate(bool compress, zip_uint32_t compression_flags, zip_error_t *error) {
struct ctx *ctx;
if ((ctx = (struct ctx *)malloc(sizeof(*ctx))) == NULL) {
@@ -67,8 +67,10 @@ allocate(bool compress, int compression_flags, zip_error_t *error) {
ctx->error = error;
ctx->compress = compress;
- ctx->compression_flags = compression_flags;
- if (ctx->compression_flags < 1 || ctx->compression_flags > 9) {
+ if (compression_flags >= 1 && compression_flags <= 9) {
+ ctx->compression_flags = (int)compression_flags;
+ }
+ else {
ctx->compression_flags = 9;
}
ctx->end_of_input = false;
@@ -82,13 +84,15 @@ allocate(bool compress, int compression_flags, zip_error_t *error) {
static void *
-compress_allocate(zip_uint16_t method, int compression_flags, zip_error_t *error) {
+compress_allocate(zip_uint16_t method, zip_uint32_t compression_flags, zip_error_t *error) {
+ (void)method;
return allocate(true, compression_flags, error);
}
static void *
-decompress_allocate(zip_uint16_t method, int compression_flags, zip_error_t *error) {
+decompress_allocate(zip_uint16_t method, zip_uint32_t compression_flags, zip_error_t *error) {
+ (void)method;
return allocate(false, compression_flags, error);
}
@@ -103,6 +107,7 @@ deallocate(void *ud) {
static zip_uint16_t
general_purpose_bit_flags(void *ud) {
+ (void)ud;
return 0;
}
@@ -132,8 +137,6 @@ map_error(int ret) {
case BZ_IO_ERROR:
case BZ_OUTBUFF_FULL:
case BZ_SEQUENCE_ERROR:
- return ZIP_ER_INTERNAL;
-
default:
return ZIP_ER_INTERNAL;
}
@@ -144,6 +147,9 @@ start(void *ud, zip_stat_t *st, zip_file_attributes_t *attributes) {
struct ctx *ctx = (struct ctx *)ud;
int ret;
+ (void)st;
+ (void)attributes;
+
ctx->zstr.avail_in = 0;
ctx->zstr.next_in = NULL;
ctx->zstr.avail_out = 0;
@@ -213,6 +219,7 @@ end_of_input(void *ud) {
static zip_compression_status_t
process(void *ud, zip_uint8_t *data, zip_uint64_t *length) {
struct ctx *ctx = (struct ctx *)ud;
+ unsigned int avail_out;
int ret;
@@ -221,7 +228,8 @@ process(void *ud, zip_uint8_t *data, zip_uint64_t *length) {
return ZIP_COMPRESSION_NEED_DATA;
}
- ctx->zstr.avail_out = (unsigned int)ZIP_MIN(UINT_MAX, *length);
+ avail_out = (unsigned int)ZIP_MIN(UINT_MAX, *length);
+ ctx->zstr.avail_out = avail_out;
ctx->zstr.next_out = (char *)data;
if (ctx->compress) {
@@ -231,7 +239,7 @@ process(void *ud, zip_uint8_t *data, zip_uint64_t *length) {
ret = BZ2_bzDecompress(&ctx->zstr);
}
- *length = *length - ctx->zstr.avail_out;
+ *length = avail_out - ctx->zstr.avail_out;
switch (ret) {
case BZ_FINISH_OK: /* compression */