http_connection gzip fix

This commit is contained in:
Arvid Norberg 2009-12-06 02:38:10 +00:00
parent 9571fd566f
commit 0f0fb82407
2 changed files with 2 additions and 2 deletions

View File

@ -65,7 +65,7 @@ namespace libtorrent
const int total_size = size; const int total_size = size;
// The zip header cannot be shorter than 10 bytes // The zip header cannot be shorter than 10 bytes
if (size < 10) return -1; if (size < 10 || buf == 0) return -1;
// check the magic header of gzip // check the magic header of gzip
if ((buffer[0] != GZIP_MAGIC0) || (buffer[1] != GZIP_MAGIC1)) return -1; if ((buffer[0] != GZIP_MAGIC0) || (buffer[1] != GZIP_MAGIC1)) return -1;

View File

@ -484,7 +484,7 @@ void http_connection::callback(error_code const& e, char const* data, int size)
if (m_bottled && m_parser.header_finished()) if (m_bottled && m_parser.header_finished())
{ {
std::string const& encoding = m_parser.header("content-encoding"); std::string const& encoding = m_parser.header("content-encoding");
if (encoding == "gzip" || encoding == "x-gzip") if ((encoding == "gzip" || encoding == "x-gzip") && size > 0 && data)
{ {
std::string error; std::string error;
if (inflate_gzip(data, size, buf, max_bottled_buffer, error)) if (inflate_gzip(data, size, buf, max_bottled_buffer, error))