From: Gunnar Beutner Date: Wed, 31 Jan 2018 08:05:06 +0000 (+0100) Subject: Add HTTP Header size limits X-Git-Tag: v2.9.0~157^2~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a9f2a8de19a0740ccc5c82ca9ccadf4e1b819890;p=icinga2 Add HTTP Header size limits --- diff --git a/lib/remote/httprequest.cpp b/lib/remote/httprequest.cpp index b85a3d0ec..11480d86a 100644 --- a/lib/remote/httprequest.cpp +++ b/lib/remote/httprequest.cpp @@ -41,8 +41,15 @@ bool HttpRequest::Parse(StreamReadContext& src, bool may_wait) String line; 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; + } + + if (line.GetLength() > 512) + BOOST_THROW_EXCEPTION(std::invalid_argument("Line length for HTTP header exceeded")); if (m_State == HttpRequestStart) { /* ignore trailing new-lines */ @@ -79,6 +86,9 @@ bool HttpRequest::Parse(StreamReadContext& src, bool may_wait) return true; } else { + if (Headers->GetLength() > 128) + BOOST_THROW_EXCEPTION(std::invalid_argument("Maximum number of HTTP request headers exceeded")); + String::SizeType pos = line.FindFirstOf(":"); if (pos == String::NPos) BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid HTTP request"));