aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-08-23 20:11:13 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-08-23 20:18:18 +0200
commit61ead1d27806801fa0b4f4501938c3d044f776fc (patch)
tree70ced39589b78ff19f958d61b7891fbb3e0250e5 /lib
parentd807cf258ba7a70ee4607294057701cb7a515c5d (diff)
Cleanup gzip range clamping code
The zlib library uses a typedef'd uInt type for ranges which may be smaller than size_t. The complicated clamping to the uInt range is technically not needed, as the buffer size can grow at most to BUFSZ anyway, and it also confuses coverity. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib')
-rw-r--r--lib/io/uncompress/gzip.c19
1 files changed, 2 insertions, 17 deletions
diff --git a/lib/io/uncompress/gzip.c b/lib/io/uncompress/gzip.c
index 1d6274c..bce7f0a 100644
--- a/lib/io/uncompress/gzip.c
+++ b/lib/io/uncompress/gzip.c
@@ -18,7 +18,6 @@ static int precache(istream_t *base)
{
istream_t *wrapped = ((istream_comp_t *)base)->wrapped;
istream_gzip_t *gzip = (istream_gzip_t *)base;
- size_t avail_in, avail_out;
int ret;
for (;;) {
@@ -26,22 +25,8 @@ static int precache(istream_t *base)
if (ret != 0)
return ret;
- avail_in = wrapped->buffer_used;
- avail_out = BUFSZ - base->buffer_used;
-
- if (sizeof(size_t) > sizeof(uInt)) {
- gzip->strm.avail_in = ~((uInt)0U);
- gzip->strm.avail_out = ~((uInt)0U);
-
- if ((size_t)gzip->strm.avail_in > avail_in)
- gzip->strm.avail_in = (uInt)avail_in;
-
- if ((size_t)gzip->strm.avail_out > avail_out)
- gzip->strm.avail_out = (uInt)avail_out;
- } else {
- gzip->strm.avail_in = (uInt)avail_in;
- gzip->strm.avail_out = (uInt)avail_out;
- }
+ gzip->strm.avail_in = (uInt)wrapped->buffer_used;
+ gzip->strm.avail_out = (uInt)(BUFSZ - base->buffer_used);
gzip->strm.next_in = wrapped->buffer;
gzip->strm.next_out = base->buffer + base->buffer_used;