aboutsummaryrefslogtreecommitdiff
path: root/net/dcsctp/packet/error_cause/missing_mandatory_parameter_cause_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'net/dcsctp/packet/error_cause/missing_mandatory_parameter_cause_test.cc')
-rw-r--r--net/dcsctp/packet/error_cause/missing_mandatory_parameter_cause_test.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/net/dcsctp/packet/error_cause/missing_mandatory_parameter_cause_test.cc b/net/dcsctp/packet/error_cause/missing_mandatory_parameter_cause_test.cc
index 8c0434050d..1c526ff0e2 100644
--- a/net/dcsctp/packet/error_cause/missing_mandatory_parameter_cause_test.cc
+++ b/net/dcsctp/packet/error_cause/missing_mandatory_parameter_cause_test.cc
@@ -22,6 +22,7 @@
namespace dcsctp {
namespace {
using ::testing::ElementsAre;
+using ::testing::IsEmpty;
TEST(MissingMandatoryParameterCauseTest, SerializeAndDeserialize) {
uint16_t parameter_types[] = {1, 2, 3};
@@ -37,5 +38,22 @@ TEST(MissingMandatoryParameterCauseTest, SerializeAndDeserialize) {
EXPECT_THAT(deserialized.missing_parameter_types(), ElementsAre(1, 2, 3));
}
+TEST(MissingMandatoryParameterCauseTest, HandlesDeserializeZeroParameters) {
+ uint8_t serialized[] = {0, 2, 0, 8, 0, 0, 0, 0};
+
+ ASSERT_HAS_VALUE_AND_ASSIGN(
+ MissingMandatoryParameterCause deserialized,
+ MissingMandatoryParameterCause::Parse(serialized));
+
+ EXPECT_THAT(deserialized.missing_parameter_types(), IsEmpty());
+}
+
+TEST(MissingMandatoryParameterCauseTest, HandlesOverflowParameterCount) {
+ // 0x80000004 * 2 = 2**32 + 8 -> if overflow, would validate correctly.
+ uint8_t serialized[] = {0, 2, 0, 8, 0x80, 0x00, 0x00, 0x04};
+
+ EXPECT_FALSE(MissingMandatoryParameterCause::Parse(serialized).has_value());
+}
+
} // namespace
} // namespace dcsctp