From 0c3dec6ff05fd95c576ee5f9c486cdee4e885622 Mon Sep 17 00:00:00 2001 From: Aaron Avery Date: Thu, 11 May 2017 11:37:43 -0500 Subject: [PATCH 1/2] The entire body has already been placed in partial_parsed, so don't direct the callback to append any more data --- .../protocol/http/client/connection/async_protocol_handler.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boost/network/protocol/http/client/connection/async_protocol_handler.hpp b/boost/network/protocol/http/client/connection/async_protocol_handler.hpp index 6e31ae6b9..2a86ca502 100644 --- a/boost/network/protocol/http/client/connection/async_protocol_handler.hpp +++ b/boost/network/protocol/http/client/connection/async_protocol_handler.hpp @@ -391,7 +391,7 @@ struct http_async_protocol_handler { partial_parsed.append(part_begin, it); part_begin = part.begin(); if (check_parse_body_complete()) { - callback(boost::asio::error::eof, bytes); + callback(boost::asio::error::eof, 0); } else { delegate_->read_some( boost::asio::mutable_buffers_1(part.data(), part.size()), callback); From 3ad7753865e5c34ca5684f8cb32db3c2ac481c34 Mon Sep 17 00:00:00 2001 From: Aaron Avery Date: Thu, 11 May 2017 11:59:51 -0500 Subject: [PATCH 2/2] Cleaned up indentation. Don't potentially access memory beyond the end of the string buffer. In the case of a partial chunk, exit the loop. Continuing to search for crlf in the middle of a binary data chunk can result in an infinite loop, and wasn't the right logic. --- .../client/connection/async_protocol_handler.hpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/boost/network/protocol/http/client/connection/async_protocol_handler.hpp b/boost/network/protocol/http/client/connection/async_protocol_handler.hpp index 2a86ca502..aad3e160b 100644 --- a/boost/network/protocol/http/client/connection/async_protocol_handler.hpp +++ b/boost/network/protocol/http/client/connection/async_protocol_handler.hpp @@ -361,13 +361,12 @@ struct http_async_protocol_handler { for (typename string_type::const_iterator iter = std::search(begin, partial_parsed.end(), crlf.begin(), crlf.end()); iter != partial_parsed.end(); - iter = - std::search(begin, partial_parsed.end(), crlf.begin(), crlf.end())) { + iter = std::search(begin, partial_parsed.end(), crlf.begin(), crlf.end())) { string_type line(begin, iter); if (line.empty()) { - std::advance(iter, 2); - begin = iter; - continue; + std::advance(iter, 2); + begin = iter; + continue; } std::stringstream stream(line); int len; @@ -375,8 +374,10 @@ struct http_async_protocol_handler { std::advance(iter, 2); if (!len) return true; if (len <= partial_parsed.end() - iter) { - std::advance(iter, len + 2); - } + std::advance(iter, len); + } else { + return false; + } begin = iter; } return false; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy