diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-09-09 12:25:31 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-09-09 12:25:31 +0100 |
commit | 0b51255f334ced4362257fc2c93a48489c2ec55e (patch) | |
tree | da9fbfe6c97e78adc1cd923ccacab8e860f7f8f3 /src/libutil | |
parent | 0835db27a1bd8b61e9ca2fda14072e6f924e248f (diff) | |
download | rspamd-0b51255f334ced4362257fc2c93a48489c2ec55e.tar.gz rspamd-0b51255f334ced4362257fc2c93a48489c2ec55e.zip |
[Fix] Try to fix unzip function
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/util.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/libutil/util.c b/src/libutil/util.c index deba3e807..d3c4721bd 100644 --- a/src/libutil/util.c +++ b/src/libutil/util.c @@ -2295,21 +2295,20 @@ rspamd_fstring_gunzip(rspamd_fstring_t **in) gsize total_out = 0; do { - strm.next_out = out->str; - strm.avail_out = out->allocated; + strm.next_out = out->str + total_out; + strm.avail_out = out->allocated - total_out; ret = inflate(&strm, Z_NO_FLUSH); if (ret != Z_OK && ret != Z_STREAM_END && ret != Z_BUF_ERROR) { break; } - gsize out_size = out->allocated - strm.avail_out; - if (total_out + out_size > out->allocated) { - out = rspamd_fstring_grow(out, total_out + out_size); + gsize out_remain = strm.avail_out; + total_out = out->allocated - out_remain; + if (out_remain == 0 && ret != Z_STREAM_END) { + out = rspamd_fstring_grow(out, out->allocated * 2); } - total_out += out_size; - } while (ret != Z_STREAM_END); if (ret == Z_STREAM_END) { |