mirror of https://github.com/Icinga/icinga2.git
Add validation for HTTP connection sizes
This commit is contained in:
parent
c7ae986d94
commit
2789d1a859
|
@ -37,6 +37,8 @@ StreamReadStatus HttpChunkedEncoding::ReadChunkFromStream(const Stream::Ptr& str
|
|||
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;
|
||||
|
|
|
@ -126,7 +126,12 @@ bool HttpRequest::Parse(StreamReadContext& src, bool may_wait)
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue