Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb930b8e

Browse files
LoopinFooldeanberris
authored andcommitted
Fix chunk and content-length encoding (#759)
* The entire body has already been placed in partial_parsed, so don't direct the callback to append any more data* 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.
1 parentcef6472 commitb930b8e

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

‎boost/network/protocol/http/client/connection/async_protocol_handler.hpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -361,22 +361,23 @@ struct http_async_protocol_handler {
361361
for (typename string_type::const_iterator iter =
362362
std::search(begin, partial_parsed.end(), crlf.begin(), crlf.end());
363363
iter != partial_parsed.end();
364-
iter =
365-
std::search(begin, partial_parsed.end(), crlf.begin(), crlf.end())) {
364+
iter =std::search(begin, partial_parsed.end(), crlf.begin(), crlf.end())) {
366365
string_typeline(begin, iter);
367366
if (line.empty()) {
368-
std::advance(iter,2);
369-
begin = iter;
370-
continue;
367+
std::advance(iter,2);
368+
begin = iter;
369+
continue;
371370
}
372371
std::stringstreamstream(line);
373372
int len;
374373
stream >> std::hex >> len;
375374
std::advance(iter,2);
376375
if (!len)returntrue;
377376
if (len <= partial_parsed.end() - iter) {
378-
std::advance(iter, len +2);
379-
}
377+
std::advance(iter, len);
378+
}else {
379+
returnfalse;
380+
}
380381
begin = iter;
381382
}
382383
returnfalse;
@@ -391,7 +392,7 @@ struct http_async_protocol_handler {
391392
partial_parsed.append(part_begin, it);
392393
part_begin = part.begin();
393394
if (check_parse_body_complete()) {
394-
callback(boost::asio::error::eof,bytes);
395+
callback(boost::asio::error::eof,0);
395396
}else {
396397
delegate_->read_some(
397398
boost::asio::mutable_buffers_1(part.data(), part.size()), callback);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp