Skip to content

Commit 58e7da1

Browse files
authored
[pw_fuzzer] Fix build failure + add coverage to payload decoder fuzztest (#35828)
* Fix error due to missing std namespace specifier * Adding More protocol types (including invalid types) to Fuzzed Payload Decoder
1 parent 9c6c365 commit 58e7da1

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/lib/dnssd/minimal_mdns/tests/FuzzPacketParsingPW.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void TxtResponderFuzz(const std::vector<std::uint8_t> & aRecord)
9696
auto equal_sign_pos = aRecord.end();
9797

9898
// This test is only giving a set of values, it can be gives more
99-
vector<uint8_t> prefixedRecord{ static_cast<uint8_t>(aRecord.size()) };
99+
std::vector<uint8_t> prefixedRecord{ static_cast<std::uint8_t>(aRecord.size()) };
100100

101101
prefixedRecord.insert(prefixedRecord.end(), aRecord.begin(), aRecord.end());
102102

@@ -126,6 +126,6 @@ void TxtResponderFuzz(const std::vector<std::uint8_t> & aRecord)
126126
}
127127
}
128128

129-
FUZZ_TEST(MinimalmDNS, TxtResponderFuzz).WithDomains(Arbitrary<vector<uint8_t>>().WithMaxSize(254));
129+
FUZZ_TEST(MinimalmDNS, TxtResponderFuzz).WithDomains(Arbitrary<std::vector<std::uint8_t>>().WithMaxSize(254));
130130

131131
} // namespace

src/lib/format/tests/FuzzPayloadDecoderPW.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,17 @@ void RunDecodeFuzz(const std::vector<std::uint8_t> & bytes, chip::Protocols::Id
5959
}
6060
}
6161

62-
// This function allows us to fuzz using one of four protocols; by using FuzzTests's `ElementOf` API, we define an
62+
// This function allows us to fuzz using all existing protocols; by using FuzzTests's `ElementOf` API, we define an
6363
// input domain by explicitly enumerating the set of values in it More Info:
6464
// https://github.com/google/fuzztest/blob/main/doc/domains-reference.md#elementof-domains-element-of
6565
auto AnyProtocolID()
6666
{
67+
// Adding an Invalid Protocol
68+
static constexpr chip::Protocols::Id InvalidProtocolID(chip::VendorId::Common, 2121);
69+
6770
return ElementOf({ chip::Protocols::SecureChannel::Id, chip::Protocols::InteractionModel::Id, chip::Protocols::BDX::Id,
68-
chip::Protocols::UserDirectedCommissioning::Id });
71+
chip::Protocols::UserDirectedCommissioning::Id, chip::Protocols::Echo::Id, chip::Protocols::NotSpecified,
72+
InvalidProtocolID });
6973
}
7074

7175
FUZZ_TEST(PayloadDecoder, RunDecodeFuzz).WithDomains(Arbitrary<std::vector<std::uint8_t>>(), AnyProtocolID(), Arbitrary<uint8_t>());

0 commit comments

Comments
 (0)