diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c1f2247..80358982 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ +* Extra logic error detection in http parser. * Move Windows CI to Drone. -------------------------------------------------------------------------------- diff --git a/include/boost/beast/http/impl/basic_parser.ipp b/include/boost/beast/http/impl/basic_parser.ipp index 64b402c8..6fac00c3 100644 --- a/include/boost/beast/http/impl/basic_parser.ipp +++ b/include/boost/beast/http/impl/basic_parser.ipp @@ -82,7 +82,17 @@ basic_parser:: put(net::const_buffer buffer, error_code& ec) { - BOOST_ASSERT(state_ != state::complete); + // If this goes off you have tried to parse more data after the parser + // has completed. A common cause of this is re-using a parser, which is + // not supported. If you need to re-use a parser, consider storing it + // in an optional. Then reset() and emplace() prior to parsing each new + // message. + BOOST_ASSERT(!is_done()); + if (is_done()) + { + ec = error::stale_parser; + return 0; + } auto p = static_cast(buffer.data()); auto n = buffer.size(); auto const p0 = p;