Skip to content

Commit

Permalink
Fix fuzzing handling of too-large inputs. (#14353)
Browse files Browse the repository at this point in the history
If we can't put it in a PacketBuffer, we can't do anything with it.

Fixes #14348
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Feb 21, 2024
1 parent 1cb7706 commit 2606809
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/all-clusters-app/linux/fuzzing-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t * aData, size_t aSize)
Transport::PeerAddress peerAddr;
System::PacketBufferHandle buf =
System::PacketBufferHandle::NewWithData(aData, aSize, /* aAdditionalSize = */ 0, /* aReservedSize = */ 0);
if (buf.IsNull())
{
// Too big; we couldn't represent this as a packetbuffer to start with.
return 0;
}

// Ignoring the return value from OnMessageReceived, because we might be
// passing it all sorts of garbage that will cause it to fail.
Expand Down

0 comments on commit 2606809

Please sign in to comment.