msgbuf << std::hex << line;
msgbuf >> context.LengthIndicator;
+ if (context.LengthIndicator < 0)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("HTTP chunk length must not be negative."));
}
StreamReadContext& scontext = context.StreamContext;
src.MustRead = false;
}
- size_t length_indicator = Convert::ToLong(Headers->Get("content-length"));
+ long length_indicator_signed = Convert::ToLong(Headers->Get("content-length"));
+
+ if (length_indicator_signed < 0)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Content-Length must not be negative."));
+
+ size_t length_indicator = length_indicator_signed;
if (src.Size < length_indicator) {
src.MustRead = true;