mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-26 23:24:09 +02:00
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++) {
|
for (size_t i = 0; i < context.Size; i++) {
|
||||||
if (context.Buffer[i] == ':') {
|
if (context.Buffer[i] == ':') {
|
||||||
header_length = 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;
|
break;
|
||||||
} else if (i > 16)
|
} else if (i > 16)
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid NetString (missing :)"));
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid NetString (missing :)"));
|
||||||
@ -61,10 +66,6 @@ StreamReadStatus NetString::ReadStringFromStream(const Stream::Ptr& stream, Stri
|
|||||||
return StatusNeedData;
|
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 */
|
/* no leading zeros allowed */
|
||||||
if (context.Buffer[0] == '0' && isdigit(context.Buffer[1]))
|
if (context.Buffer[0] == '0' && isdigit(context.Buffer[1]))
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid NetString (leading zero)"));
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid NetString (leading zero)"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user