mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-22 21:24:41 +02:00
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 << std::hex << line;
|
||||||
msgbuf >> context.LengthIndicator;
|
msgbuf >> context.LengthIndicator;
|
||||||
|
|
||||||
|
if (context.LengthIndicator < 0)
|
||||||
|
BOOST_THROW_EXCEPTION(std::invalid_argument("HTTP chunk length must not be negative."));
|
||||||
}
|
}
|
||||||
|
|
||||||
StreamReadContext& scontext = context.StreamContext;
|
StreamReadContext& scontext = context.StreamContext;
|
||||||
|
@ -126,7 +126,12 @@ bool HttpRequest::Parse(StreamReadContext& src, bool may_wait)
|
|||||||
src.MustRead = false;
|
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) {
|
if (src.Size < length_indicator) {
|
||||||
src.MustRead = true;
|
src.MustRead = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user