Skip to content

Commit ac53b3c

Browse files
committed
1. using Enum value Transport::Type::kNumofTypes to fuzz the number of transport types
2. using different parts of the fuzzed input data for TransportType and for Payload
1 parent 565d7f5 commit ac53b3c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

examples/all-clusters-app/linux/fuzzing-main.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,17 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t * aData, size_t aSize)
7474
// But maybe we should try to separately extract a PeerAddress and data from
7575
// the incoming data?
7676

77-
// dumping payload with random transport types
78-
Transport::Type fuzzedTransportType = static_cast<Transport::Type>(*aData % 5);
77+
// dumping payload with fuzzed transport types
78+
Transport::Type fuzzedTransportType = static_cast<Transport::Type>(aData[0] % static_cast<uint8_t>(Transport::Type::kNumofTypes));
7979
Transport::PeerAddress peerAddr(fuzzedTransportType);
8080

81+
if (aSize < 1)
82+
{
83+
return 0;
84+
}
85+
8186
System::PacketBufferHandle buf =
82-
System::PacketBufferHandle::NewWithData(aData, aSize, /* aAdditionalSize = */ 0, /* aReservedSize = */ 0);
87+
System::PacketBufferHandle::NewWithData(&aData[1], aSize - 1, /* aAdditionalSize = */ 0, /* aReservedSize = */ 0);
8388
if (buf.IsNull())
8489
{
8590
// Too big; we couldn't represent this as a packetbuffer to start with.

0 commit comments

Comments
 (0)