File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ class basic_parser
7878 std::uint64_t len0_ = 0 ; // content length if known
7979 std::unique_ptr<char []> buf_; // temp storage
8080 std::size_t buf_len_ = 0 ; // size of buf_
81+ std::size_t skip_ = 0 ; // resume search here
8182 std::uint32_t header_limit_ = 8192 ; // max header size
8283 unsigned short status_ = 0 ; // response status
8384 state state_ = state::nothing_yet; // initial state
Original file line number Diff line number Diff line change @@ -164,6 +164,7 @@ loop:
164164 parse_chunk_header (p, n, ec);
165165 if (ec)
166166 goto done;
167+ BOOST_ASSERT (! skip_);
167168 if (state_ != state::trailer_fields)
168169 break ;
169170 n = static_cast <std::size_t >(p1 - p);
@@ -590,7 +591,7 @@ parse_chunk_header(char const*& in,
590591 auto p = in;
591592 auto const pend = p + n;
592593
593- if (n < 2 )
594+ if (n < skip_ + 2 )
594595 {
595596 BOOST_BEAST_ASSIGN_EC (ec, error::need_more);
596597 return ;
@@ -607,14 +608,17 @@ parse_chunk_header(char const*& in,
607608 }
608609 }
609610
610- auto const eol = find_eol (p, pend, ec);
611+ auto const eol = find_eol (p + skip_ , pend, ec);
611612 if (ec)
612613 return ;
613614 if (! eol)
614615 {
615616 BOOST_BEAST_ASSIGN_EC (ec, error::need_more);
617+ if (p != pend)
618+ skip_ = pend - p - 1 ;
616619 return ;
617620 }
621+ skip_ = static_cast <std::size_t >(eol - p - 2 );
618622
619623 std::uint64_t size;
620624 if (! parse_hex (p, size))
@@ -647,6 +651,7 @@ parse_chunk_header(char const*& in,
647651 return ;
648652
649653 len_ = size;
654+ skip_ = 0 ;
650655 in = eol;
651656 f_ |= flagExpectCRLF;
652657 if (size != 0 )
You can’t perform that action at this time.
0 commit comments