Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
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.
  • Loading branch information
Aaron Avery committed May 11, 2017
commit 3ad7753865e5c34ca5684f8cb32db3c2ac481c34
Original file line number Diff line number Diff line change
Expand Up @@ -361,22 +361,23 @@ 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;
stream >> std::hex >> len;
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;
Expand Down