summaryrefslogtreecommitdiff
path: root/lib/sqfs/comp/gzip.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-27 18:43:07 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-27 18:43:07 +0200
commitcdb1c79153b2b1377fa0ca7e1beda2b6b9b2c687 (patch)
tree18217e4bdff2e4e37adccbb7e078623f4fac3e6b /lib/sqfs/comp/gzip.c
parent40232f4bd4d7e8e001f7d1e8f120606f59b2c147 (diff)
Remove use of ssize_t from library API
ssize_t is only available on POSIX platforms and even there it is only defined to hold at least -1 in the range of negative numbers. This commit replaces ssize_t return types with sqfs_s32 and the coresponding function arguments with sqfs_u32. Because the range of positiv numbers for a signed 32 bit number is only half that of the unsigned version, additional checks have to be added. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/comp/gzip.c')
-rw-r--r--lib/sqfs/comp/gzip.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/sqfs/comp/gzip.c b/lib/sqfs/comp/gzip.c
index 3dd8d10..3886e60 100644
--- a/lib/sqfs/comp/gzip.c
+++ b/lib/sqfs/comp/gzip.c
@@ -107,7 +107,7 @@ static int flag_to_zlib_strategy(int flag)
}
static int find_strategy(gzip_compressor_t *gzip, const sqfs_u8 *in,
- size_t size, sqfs_u8 *out, size_t outsize)
+ sqfs_u32 size, sqfs_u8 *out, sqfs_u32 outsize)
{
int ret, strategy, selected = Z_DEFAULT_STRATEGY;
size_t i, length, minlength = 0;
@@ -148,13 +148,16 @@ static int find_strategy(gzip_compressor_t *gzip, const sqfs_u8 *in,
return selected;
}
-static ssize_t gzip_do_block(sqfs_compressor_t *base, const sqfs_u8 *in,
- size_t size, sqfs_u8 *out, size_t outsize)
+static sqfs_s32 gzip_do_block(sqfs_compressor_t *base, const sqfs_u8 *in,
+ sqfs_u32 size, sqfs_u8 *out, sqfs_u32 outsize)
{
gzip_compressor_t *gzip = (gzip_compressor_t *)base;
int ret, strategy = 0;
size_t written;
+ if (size >= 0x7FFFFFFF)
+ return 0;
+
if (gzip->compress && gzip->opt.strategies != 0) {
strategy = find_strategy(gzip, in, size, out, outsize);
if (strategy < 0)
@@ -193,7 +196,7 @@ static ssize_t gzip_do_block(sqfs_compressor_t *base, const sqfs_u8 *in,
if (gzip->compress && written >= size)
return 0;
- return (ssize_t)written;
+ return written;
}
if (ret != Z_OK && ret != Z_BUF_ERROR)