From 40097d776b092c40c606da09d58eac29b1bb9834 Mon Sep 17 00:00:00 2001 From: sowle Date: Wed, 18 Mar 2020 15:22:20 +0300 Subject: [PATCH] epee:: http_client & gzip_encoding: fixed improper handling of incorrect gzip data during downloading --- contrib/epee/include/gzip_encoding.h | 4 ++++ contrib/epee/include/net/http_client.h | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/contrib/epee/include/gzip_encoding.h b/contrib/epee/include/gzip_encoding.h index 65968ff4..8b6721fa 100644 --- a/contrib/epee/include/gzip_encoding.h +++ b/contrib/epee/include/gzip_encoding.h @@ -150,6 +150,10 @@ namespace net_utils return false; } } + else + { + CHECK_AND_ASSERT_MES(Z_DATA_ERROR != ret, false, "content_encoding_gzip::update_in() Failed to inflate. err = Z_DATA_ERROR"); + } //leave only unpacked part in the output buffer to start with it the next time diff --git a/contrib/epee/include/net/http_client.h b/contrib/epee/include/net/http_client.h index 492b4aab..001d7ceb 100644 --- a/contrib/epee/include/net/http_client.h +++ b/contrib/epee/include/net/http_client.h @@ -464,7 +464,14 @@ using namespace std; } CHECK_AND_ASSERT_MES(m_len_in_remain >= recv_buff.size(), false, "m_len_in_remain >= recv_buff.size()"); m_len_in_remain -= recv_buff.size(); - m_pcontent_encoding_handler->update_in(recv_buff); + bool r = m_pcontent_encoding_handler->update_in(recv_buff); + //CHECK_AND_ASSERT_MES(m_len_in_remain >= recv_buff.size(), false, "m_pcontent_encoding_handler->update_in returned false"); + if (!r) + { + m_state = reciev_machine_state_error; + disconnect(); + return false; + } if(m_len_in_remain == 0) m_state = reciev_machine_state_done;