mirror of https://github.com/Icinga/icinga2.git
Fix incorrect header length check in NetString::ReadStringFromStream
This commit is contained in:
parent
1e9e5edcff
commit
79a69d3e89
|
@ -51,6 +51,11 @@ StreamReadStatus NetString::ReadStringFromStream(const Stream::Ptr& stream, Stri
|
|||
for (size_t i = 0; i < context.Size; i++) {
|
||||
if (context.Buffer[i] == ':') {
|
||||
header_length = i;
|
||||
|
||||
/* make sure there's a header */
|
||||
if (header_length == 0)
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid NetString (no length specifier)"));
|
||||
|
||||
break;
|
||||
} else if (i > 16)
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid NetString (missing :)"));
|
||||
|
@ -61,10 +66,6 @@ StreamReadStatus NetString::ReadStringFromStream(const Stream::Ptr& stream, Stri
|
|||
return StatusNeedData;
|
||||
}
|
||||
|
||||
/* make sure there's a header */
|
||||
if (header_length == 0)
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid NetString (no length specifier)"));
|
||||
|
||||
/* no leading zeros allowed */
|
||||
if (context.Buffer[0] == '0' && isdigit(context.Buffer[1]))
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid NetString (leading zero)"));
|
||||
|
|
Loading…
Reference in New Issue