diff options
author | Dr. Lars Völker <lars.voelker@technica-engineering.de> | 2022-01-14 21:21:49 +0100 |
---|---|---|
committer | A Wireshark GitLab Utility <gerald+gitlab-utility@wireshark.org> | 2022-01-15 08:30:36 +0000 |
commit | dd663c8c7f40fa4aeaef48995a784683faf62a43 (patch) | |
tree | 8f54d80d79210ad98a9f793a137af36b64ef3fe4 /wiretap/blf.c | |
parent | e9d650362c41c6f63e81b14a9a4e3833680af4d1 (diff) |
BLF: Improve handling of zlib errors
Diffstat (limited to 'wiretap/blf.c')
-rw-r--r-- | wiretap/blf.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/wiretap/blf.c b/wiretap/blf.c index 89a59b988a..91196e5b6d 100644 --- a/wiretap/blf.c +++ b/wiretap/blf.c @@ -490,10 +490,32 @@ blf_pull_logcontainer_into_memory(blf_params_t *params, guint index_log_containe infstream.avail_out = (unsigned int)tmp.real_length; infstream.next_out = buf; - // the actual DE-compression work. - inflateInit(&infstream); - inflate(&infstream, Z_NO_FLUSH); - inflateEnd(&infstream); + /* the actual DE-compression work. */ + if (Z_OK != inflateInit(&infstream)) { + ws_debug("inflateInit failed for LogContainer %d", index_log_container); + if (infstream.msg != NULL) { + ws_debug("inflateInit returned: \"%s\"", infstream.msg); + } + return FALSE; + } + + int ret = inflate(&infstream, Z_NO_FLUSH); + /* Z_OK should not happen here since we know how big the buffer should be */ + if (Z_STREAM_END != ret) { + ws_debug("inflate failed (return code %d) for LogContainer %d", ret, index_log_container); + if (infstream.msg != NULL) { + ws_debug("inflate returned: \"%s\"", infstream.msg); + } + return FALSE; + } + + if (Z_OK != inflateEnd(&infstream)) { + ws_debug("inflateEnd failed for LogContainer %d", index_log_container); + if (infstream.msg != NULL) { + ws_debug("inflateEnd returned: \"%s\"", infstream.msg); + } + return FALSE; + } tmp.real_data = buf; g_array_index(blf_data->log_containers, blf_log_container_t, index_log_container) = tmp; |