diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2024-02-04 18:23:40 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2024-02-04 18:23:40 +0100 |
commit | b7ecf93a22240e949038210a23549270a5bfd4af (patch) | |
tree | 52f6517510e5681cffcac8d0df5f25cff97779c4 | |
parent | 162dc87796abe6b36ef0290f5f94ead7f45fd5a4 (diff) | |
download | weechat-b7ecf93a22240e949038210a23549270a5bfd4af.zip |
relay: fix websocket decompression when output buffer is not large enough
-rw-r--r-- | src/plugins/relay/relay-websocket.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/plugins/relay/relay-websocket.c b/src/plugins/relay/relay-websocket.c index 760128c01..b74fb937e 100644 --- a/src/plugins/relay/relay-websocket.c +++ b/src/plugins/relay/relay-websocket.c @@ -497,14 +497,18 @@ relay_websocket_inflate (const void *data, size_t size, z_stream *strm, while (1) { rc = inflate (strm, Z_SYNC_FLUSH); - if ((rc == Z_STREAM_END) || (rc == Z_OK)) + if (((rc == Z_STREAM_END) || (rc == Z_OK)) + && (strm->avail_in == 0)) { /* data successfully decompressed */ *size_decompressed = strm->total_out; break; } - else if (rc == Z_BUF_ERROR) + if ((rc == Z_BUF_ERROR) + || (((rc == Z_STREAM_END) || (rc == Z_OK)) + && (strm->avail_in > 0))) { + /* output buffer is not large enough */ strm->avail_out += dest_size; dest_size *= 2; dest2 = realloc (dest, dest_size); |