mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 07:34:15 +02:00
Add HTTP Header size limits
This commit is contained in:
parent
0339a2b827
commit
f5f8b90ec8
@ -45,8 +45,15 @@ bool HttpRequest::Parse(StreamReadContext& src, bool may_wait)
|
|||||||
String line;
|
String line;
|
||||||
StreamReadStatus srs = m_Stream->ReadLine(&line, src, may_wait);
|
StreamReadStatus srs = m_Stream->ReadLine(&line, src, may_wait);
|
||||||
|
|
||||||
if (srs != StatusNewItem)
|
if (srs != StatusNewItem) {
|
||||||
|
if (src.Size > 512)
|
||||||
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Line length for HTTP header exceeded"));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line.GetLength() > 512)
|
||||||
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Line length for HTTP header exceeded"));
|
||||||
|
|
||||||
if (m_State == HttpRequestStart) {
|
if (m_State == HttpRequestStart) {
|
||||||
/* ignore trailing new-lines */
|
/* ignore trailing new-lines */
|
||||||
@ -84,6 +91,9 @@ bool HttpRequest::Parse(StreamReadContext& src, bool may_wait)
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
if (Headers->GetLength() > 128)
|
||||||
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Maximum number of HTTP request headers exceeded"));
|
||||||
|
|
||||||
String::SizeType pos = line.FindFirstOf(":");
|
String::SizeType pos = line.FindFirstOf(":");
|
||||||
if (pos == String::NPos)
|
if (pos == String::NPos)
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid HTTP request"));
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid HTTP request"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user